Four Stars

Sequence not starting from previous value

Hi,

I'm trying to generate the sequence number for each newly inserted value. But when i'm inserting new records and run the job again, the sequence starts from 1 for the new values but not from the previous (max) value.

This is the expression i have used  "Numeric.sequence("s2",(row5.id == null?1:row5.id)+1,1)  ", where row5.id is the max id from aggregaterow component.

Please find the attached screenshot for reference.

 

Thanks

 

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: Sequence not starting from previous value

Try to get the current max value in a 1st subjob (reuse what you do tFileInputExcel_3 and tAggregateRow_1).

Push the result into a global variable ("curMax" in the following).

Connect the new subjob to tFileInputExcel_1 using a "On Subjob Ok" triger. 

Remove the tMap input associated to row5.

In tMap_1, set the out1 id with the following

Numeric.sequence("s2", (Integer)globalMap.get("curMax", 1))

Hope this helps.


TRF
4 REPLIES
Twelve Stars TRF
Twelve Stars

Re: Sequence not starting from previous value

Hi,

Can you share your tMap?


TRF
Four Stars

Re: Sequence not starting from previous value

Hi TRF,

 

Please find the attached screenshot of tMap.

 

Thanks

Twelve Stars TRF
Twelve Stars

Re: Sequence not starting from previous value

Try to get the current max value in a 1st subjob (reuse what you do tFileInputExcel_3 and tAggregateRow_1).

Push the result into a global variable ("curMax" in the following).

Connect the new subjob to tFileInputExcel_1 using a "On Subjob Ok" triger. 

Remove the tMap input associated to row5.

In tMap_1, set the out1 id with the following

Numeric.sequence("s2", (Integer)globalMap.get("curMax", 1))

Hope this helps.


TRF
Four Stars

Re: Sequence not starting from previous value

Thanks TRF !

It worked like a charm. Attaching the screenshot for others reference.

 

And TRF, Can you please explain what is wrong with the first version of the Job. I reckon the value of tAggregate component is not propagated correctly, isn't it ?