One Star cas
One Star

Retrieving and saving last sequence number

Hi,
I'm using Talend's sequence number and pass following value to the column:
Numeric.sequence("Last_Sequence_Fact05",1,1) .
How do I pass the value to variable Last_Sequence_Fact05 ?
Thanks
C
3 REPLIES
Seventeen Stars

Re: Retrieving and saving last sequence number

The only way is to save the last number and in the next job start you have to setup the sequence with Numeric.sequence("Last_Sequence_Fact05", context.lastNumber, 1)
But I would use a database sequence instead of job local memory sequence!
One Star cas
One Star

Re: Retrieving and saving last sequence number

thanks for your suggestion, but my main problem is not saving the value since I can retrieve it by SQL statement
I'm quite new to Talend so my problem is that I don't know how to pass a result of query:
SELECT max(qequence_num) from Fact05
to the column:
Numeric.sequence("Last_Sequence_Fact05",1,1) .
In general it is getting a value from a query and passing it to variable that could be used in other parts of the job.
c.
Seventeen Stars

Re: Retrieving and saving last sequence number

hi,
Last_Sequence_Fact05 is the name of your sequence
use globalMap to store(put) value and get it later.
syntax
(Integer)globalMap.get("your_key_name")

so in your tMap it could be something like
Numeric.sequence("Last_Sequence_Fact05",(Integer)globalMap.get("your_key_name"),1)

Ps : with Mysql you've got tMysqlLastInserId
regards