Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I want to have a sequence for one of the column and it should start the sequence from where the last run stopped.
for example if 10 was generated by sequence for first run , for second run it should start with 11.
I got the first half , to generate the sequence using numeric.sequence("s1",1,1)
can you suggest how can i implement the second part , i went through the forum but couldn't find the solution
Thanks in advance,
Prabhat
@Prabhat,please find the below way.
This is just a kind of visual representation of what I wrote before.
Nothing really new in that.
Thanks TRF for your reply.
I am not looking to store the values in file or database. Can you please tell me more about the 3rd way where we are storing the current value in context variable.
Thanks,
Prabhat
@Prabhat, sorry for the delay, here the full solution using a context file.
For the sample, the job design looks like this:
How it works:
- the context is stored in a properties file outside from the job package and loaded at runtime using the implicit tContextLoad functionality (Job properties, Extra, untick the "Use project properties" option, tick "Implicit tContextLoad, choose "From the file" and enter your filename which is "C:/Users/offic/Desktop/TestTalend/contextDump.csv" in my case, choose ";" or any thing else as the field separator)
- here is what my contextDump.csv file looks like:
hasmore; sample;100 test;0
- the context variable used to store the current value is called "sample" with an initial value of 0
- when the job starts, the tJava component print its value on the console (see the end)
- then we go to the tFixedFlowInput component which is used to compute the new value for the sample context variable. As the variable must be a String for the nex component (tContextLoad), we have a double conversion to convert the value to an Integer, add 100 to the current value and convert the result back to a String:
- tContextLoad is used to modify the value of the context variables
- tContextDump / tFileOutputDelimited write these variables with their value into the context file used when the job starts (C:/Users/offic/Desktop/TestTalend/contextDump.csv)
- finally, tJava print its new value on the console:
Démarrage du job test a 14:20 19/05/2018. [statistics] connecting to socket on port 3884 [statistics] connected Initial value:100 [statistics] disconnected Job test terminé à 14:20 19/05/2018. [Code sortie=0]
Each time the job starts, the value from the previous run is taken from the context file.
That's all.
@Prabhat, did this help you?
If so, thank's to mark this case as solved (Kudos also accepted).