Sequence not starting from previous value

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

 


Accepted Solutions
Forteen Stars TRF
Forteen 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

All Replies
Forteen Stars TRF
Forteen 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

Forteen Stars TRF
Forteen 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 ?

Four Stars

Re: Sequence not starting from previous value

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

 

How do you push the result into a global variable?

 

which component and syntax to be used?

Forteen Stars TRF
Forteen Stars

Re: Sequence not starting from previous value

Great!

Need to know what in the component to try to explain why it doesn't work as desired.

Share details if needed.


TRF
Four Stars

Re: Sequence not starting from previous value

As per your reply in the one of the post you have metioned this.

 

I am also trying to understand where do you implement this step.

 

Attached is the post that i am talking about.

Forteen Stars TRF
Forteen Stars

Re: Sequence not starting from previous value

OK.

You need to use globalMap.put method for that.

Based on the previous post, it should look like this (I assume the field containing the value to store into the global variable is called maxValue):

globalMap.put("curMax", row5.maxValue);

TRF
Four Stars

Re: Sequence not starting from previous value

Can you please check the attached screenshot and let me know if it is correctly done?

 

If it is correctly done, then also i am not able to set up the max value to the variable instead it is coming as 0.

 

Output: the max value is :0

 

Thanks in advance!