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.sequnce("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,
Solved! Go to Solution.
Please do following steps.
1) Create context parameter sequence_max_value.
2) Get Max value of sequence column.
example : SELECT max(sequence_column) AS sequence_max_value FROM table_name;
In tJavaRow check if query returns null then assign context.sequence_max_value=1 other wise context.sequence_max_value=input_row.sequence_max_value(This is max value from table);
3) In the tmap use numeric.sequnce("s1",context.sequence_max_value,1) expression.
Note : If you want you can also use ISNULL function in query and assign value 1.
in this senario,store your first run max sequnce value in file or Database,before the main you from the input file/database load seq num into context ,and the in tmap,use sequnce funation givet the current value is context value.
Thanks Manohar & Ravi for your reply.
Am not using DB,Its flat file --- so how can i get the max value
@ manohar can i know how can i store the max value.can you please provide some screenshoots that would be great help.
you were generating sequence in Var of tmap right,you just pass to one extra optput section and use the tAggregaterow componet to get the Max Values of your sequence.
I stored the value in file.when i want to store the value in the context, should i store in local or global variable , if so then how.
read the same file and loaded into context using tContextload in the main flow of same job,where you are generating the sequence in tmap