Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I want to reset the sequence based on the Column ID .here is the eg Input
Numer,sequence("S1",1,1) this wont give my result
Numeric.resetSequence("S1",1) this is not giving a result what i want.
Let me know what should i do or any solutions
ID,Amount
100,1000
100,2000
200,3000
200,4000,
200,5000
300,6000
Output i need
ID,Amount,ResetSeq
100,1000,1
100,2000,2
200,3000,1
200,4000,2
200,5000,3
300,6000,1
Hi,
The sequence name must be based on the id value.
This can be done by a tJavaRow with the following code:
if (input_row.id != ((Integer)globalMap.get("id")) && ((Integer)globalMap.get("id")) != null) { // Id change, remove previous sequence and memorize current id Numeric.removeSequence(Integer.toString((Integer)globalMap.get("id"))); globalMap.put("id", input_row.id); } output_row.id = input_row.id; output_row.amount = input_row.amount; // Initialize or get next value from current sequence output_row.sequence = Numeric.sequence(Integer.toString(input_row.id), 1, 1);
Each time the id change, the current sequence is removed and a new one is created.
According to your data sample, here is the result:
Starting job test at 22:34 03/09/2017. [statistics] connecting to socket on port 3683 [statistics] connected 100|1000|1 100|2000|2 200|3000|1 200|4000|2 200|5000|3 300|6000|1 [statistics] disconnected Job test ended at 22:34 03/09/2017. [exit code=0]
Note that all fields are defined as integers.
Hope this helps.
Use below, it will solve your problem.
Numer,sequence(input_row.ID,1,1)
Please accept solution if it works
Hi,
The sequence name must be based on the id value.
This can be done by a tJavaRow with the following code:
if (input_row.id != ((Integer)globalMap.get("id")) && ((Integer)globalMap.get("id")) != null) { // Id change, remove previous sequence and memorize current id Numeric.removeSequence(Integer.toString((Integer)globalMap.get("id"))); globalMap.put("id", input_row.id); } output_row.id = input_row.id; output_row.amount = input_row.amount; // Initialize or get next value from current sequence output_row.sequence = Numeric.sequence(Integer.toString(input_row.id), 1, 1);
Each time the id change, the current sequence is removed and a new one is created.
According to your data sample, here is the result:
Starting job test at 22:34 03/09/2017. [statistics] connecting to socket on port 3683 [statistics] connected 100|1000|1 100|2000|2 200|3000|1 200|4000|2 200|5000|3 300|6000|1 [statistics] disconnected Job test ended at 22:34 03/09/2017. [exit code=0]
Note that all fields are defined as integers.
Hope this helps.
Hello TRF,
please can you tell me where you initialize the id global variable?
cause by my side, i got a null pointer exception, and i think it is related to this variable.