Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

[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
Labels (2)
1 Solution

Accepted Solutions
alevy
Specialist
Specialist

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.

View solution in original post

8 Replies
Anonymous
Not applicable

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
Anonymous
Not applicable

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
alevy
Specialist
Specialist

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.
Anonymous
Not applicable

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
alevy
Specialist
Specialist

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.
Anonymous
Not applicable

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

thanks,
Raja K
_AnonymousUser
Specialist III
Specialist III
Author

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.
Anonymous
Not applicable

Hi, I'm facing the same problem.
For me, I'm trying to use Numeric.sequence() thinking in performance. My table will be huge in the future, and the max(id) will be more and more hard to extract.