[resolved] How do you use Numeric.sequence("s1",1,1)

One Star

[resolved] How do you use Numeric.sequence("s1",1,1)

I want to populate a field in a table with an integer. I want it to increment each time I run the job. This will be my Load Id.
I am thinking of using the Numeric.sequence() function, but I can not find any documentation on how it works or what the parameters do.
Can anyone point me to the documentation that describes this function?
If there is a better way to achieve my desired result, I would be open to suggestions.
Thank You,
Jason

Accepted Solutions
Seven Stars

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

If the file is in the order of ID, you can read the file and send the flow to tSetGlobalVar. That way the last record (with the max id) will be stored in the globalMap. You can then use it+1 as the seed for Numeric.sequence.
If the file is not in order, use tAggregateRow to get the max id and then tSetGlobalVar to store it.

All Replies
Community Manager

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

Hello
It is the method defined by Talend, you can go to Repository-->code-->system-->Numeric and read the relate d description of function.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

Hi,
i use Numeric.sequence("s1",1,1) as an autoincrement ID within one launch (so each row +1) - but now i need an auto-incremented ID for each time i launch the whole job (for the same job ID: 1 - the next time i launch the job ID: 2 a.s.o). Is this possible?
regards
alex
Seven Stars

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

Only by reading back the last ID used from your file/DB at the start of your job and storing it in globalMap so it can be used as the seed in tMap.
One Star

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

Hi Alevy,
I am using file as my output. How can I get the max id (last inserted id) from file? Then I can store it in globalMap as used for next execution.

Thanks,
Raja K
Seven Stars

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

If the file is in the order of ID, you can read the file and send the flow to tSetGlobalVar. That way the last record (with the max id) will be stored in the globalMap. You can then use it+1 as the seed for Numeric.sequence.
If the file is not in order, use tAggregateRow to get the max id and then tSetGlobalVar to store it.
One Star

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

Thank You so much for your reply. It works for me.

thanks,
Raja K
One Star

Re: [resolved] How do you use Numeric.sequence("s1",1,1)

Hi,
I want to add an Batch_ID to my job which runs daily. But this Batch ID should be unique for each run and needs to be incremental.
I created a variable which converts my job run start date into integer and gives me output in form of "yyyyMMdd". Now I want to add a unique number in front of this "yyyyMMdd", so that it serves as a BATCH_ID for that particular run. Point to be noted is, it should add only one number in front of "yyyyMMdd" for each run of the job, and should be incremental for the subsequent runs. I hope i have written my query very clearly.
I willbe grateful if someone could help me out.