Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
Hi,
Can you share your tMap?
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.
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 ?
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?
Great!
Need to know what in the component to try to explain why it doesn't work as desired.
Share details if needed.
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.
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);
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!