Skip to Content
avatar image
Former Member

Incrementing the value

Hi,

Iam doing a jdbc-to-jdbc scenario in which one of target table field has to be filled with a number in the following way.

Initially it should have 1 and for every execution of the scenario it should increase by 1 i.e for 2nd time execution it should be 2 like that....

anybody Please help me regarding this.

Thanks & Regards,

Radhika.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Aug 16, 2007 at 02:19 PM

    When the same payload contains multiple occurrences, then standard functions could be used.

    For case where the messages are separate, this needs to be handled at the receiver end itself. Or may be handled in XI using the JDBC lookup

    Another option would be to send some indicator from Sender and map accordingly.

    Regards,

    Prateek

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 02:23 PM

    Use the folllwoing UDF may help to you:

    <b> Increment the Global Variable Counter</b>

    public String incrementCounter(String a,Container container){

    if(a.equals(" "))

    {

    Object o = container.getGlobalContainer().getParameter("CNTR");

    Integer ii;

    if( o == null ) ii = new Integer(0);

    else ii = (Integer)o;

    ii = new Integer( ii.intValue() + 1);

    container.getGlobalContainer().setParameter("CNTR", ii);

    String temp = ii.toString();

    switch( temp.length() )

    {

    case 1: temp = "00"+ temp; break;

    case 2: temp = "0"+ temp; break;

    }

    return temp;

    }

    else return " ";

    <b>Intialise the Counter</b>

    Object o = container.getGlobalContainer().getParameter("CNTR");

    Integer ii = new Integer(0);;

    container.getGlobalContainer().setParameter("CNTR", ii);

    return "1";

    Warm Regards,

    Vijay

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 16, 2007 at 02:02 PM

    Hi,

    Ther is a function called Increment / Counter it will help

    Regards

    Agasthuri Doss

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 16, 2007 at 02:10 PM

    Radhika,

    Use<b> Counter</b> function.

    This sample will help you.

    http://flickr.com/photo_zoom.gne?id=1064675164&size=o

    http://flickr.com/photo_zoom.gne?id=1064675430&size=o

    Best regards,

    raj.

    Add comment
    10|10000 characters needed characters exceeded