sequence generate

Six Stars

sequence generate

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.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,

lmit


Accepted Solutions
Twelve Stars

Re: sequence generate

Thanks @lmit .Please accpect solution.

Manohar B

All Replies
Seven Stars

Re: sequence generate

Hi  lmit,

 

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.

 

 

Thanks & Regards
A Ravi Kumar
Mobile Number : +91 852-762-1083
Email-id : a.ravikumar104@gmail.com
Skype Id : ammanannaravikumar
Twelve Stars

Re: sequence generate

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.

Manohar B
Six Stars

Re: sequence generate

Hi,

 

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.

 

Thanks,

lmit

Twelve Stars

Re: sequence generate

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.

Manohar B
Six Stars

Re: sequence generate

hi Manohar,

I got the value in tAggregaterow  but i got stucked after that how should i produce further

 

Thansk,

limt

Twelve Stars

Re: sequence generate

affter tAggregaterow ,use tfileoutputdelimtter and load that value into file.

Manohar B
Six Stars

Re: sequence generate

Hi manohar,

 

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.

 

Thanks,

lmit

Twelve Stars

Re: sequence generate

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

Manohar B
Six Stars

Re: sequence generate

Thanks Manohar , will try this option.

 

Thanks once again Smiley Happy

 

Thanks,

lmit

Twelve Stars

Re: sequence generate

If this help please give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Manohar B
Twelve Stars

Re: sequence generate

Thanks @lmit .Please accpect solution.

Manohar B