Four Stars

Reset Sequence in Components

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

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: Reset Sequence in Components

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.


TRF
7 REPLIES
Six Stars

Re: Reset Sequence in Components

Use below, it will solve your problem.

Numer,sequence(input_row.ID,1,1) 

 

Please accept solution if it works

Twelve Stars TRF
Twelve Stars

Re: Reset Sequence in Components

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.


TRF
Twelve Stars TRF
Twelve Stars

Re: Reset Sequence in Components

Did it help you?

TRF
Four Stars

Re: Reset Sequence in Components

Hi
Do we have any other options other than tJavaRow
Twelve Stars TRF
Twelve Stars

Re: Reset Sequence in Components

Probably you can do it using tMap but it may be a little confusing. tJavaRow is the best solution from my point of view. Any problem with this idea?

TRF
Four Stars

Re: Reset Sequence in Components

Problem is not with the solution ..I read it some where like dont use tJavarow .until unless if its a last option..it will slow down the job like that...
Twelve Stars TRF
Twelve Stars

Re: Reset Sequence in Components

Maybe if you are looking for microseconds, else you can go on.

TRF