Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi @Shong_888 ,
I am storing max(ID) from query and in tJava.
Which I am trying to use and max(ID)+1 in
Inside tjava:
I am struggling to use it in tMap. How can I do that?
Please help!
Thanks in advance!
Amit
Define the context variable with Bigdecimal type, try this code on tJavaRow:
context.MaxID=input_row.MAX_ID.add(new java.math.BigDecimal(1));
I used the Numeric sequence is variable an and used in map.
Var.varIncrementedID = context.MaxID.add(new BigDecimal(Numeric.sequence("s1", 1, 1)))
Now it's working as expected.
Thanks,
Amit
If we can do in any other way to store the max id and use it in tMap. Idea is welcomed.
Thanks!
@Amit4 use tJavaRow instead of tJava, store the max(ID) to a context variable for used later on other components.
tJavaRow code:
context.varName=input_row.MAX_ID;
Hi @Shicong_Hong ,
I applied the logic in tJavaRow
But How can we use that variable in tMap output. Also I want it to be in the incremental form. If ID comes as 100 then it should pass as 101 in the output table.
Thanks
change the code to
context.MaxID=input_row.MAX_ID+1;
and use the context variable directly in the expression field of column.
Thanks but My ID column is of Bigdecimal data type upon adding 1 it is getting failed which is legit.
How can we deal with this data type issue.
Hello Amit,
I use the tSetGlobalVar component to store a (initial) max id value, and globalMap.get(...) to retrieve it. (I have an Integer data type that is the start value for a Numeric.Sequence(...).)
Best regards,
Thomas
If ID column is of Bigdecimal data type in output table , use this code in the expression field of column on tMap.
new java.math.BigDecimal(context.MaxID)
Source & Target both table is same and ID column is of BigDecimal data type.
If I use context.MaxID=input_row.MAX_ID+1 in tJavarow, it is throwing error because of integer addition to BigDecimal.
We need handle it before and then use it later in tmap