Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Amit4
Contributor III
Contributor III

Store Max ID using tJava and use it in tMap

Hi @Shong_888 ,

I am storing max(ID) from query and in tJava.

Which I am trying to use and max(ID)+1 in 

Amit4_0-1718016282551.png

Inside tjava:

Amit4_1-1718017688055.png

 

I am struggling to use it in tMap. How can I do that?

Amit4_3-1718017935812.png

 

Please help!

 

Thanks in advance!

 

Amit

 

 

Labels (6)
12 Replies
Shicong_Hong
Support
Support

Define the context variable with Bigdecimal type, try this code on tJavaRow:

context.MaxID=input_row.MAX_ID.add(new java.math.BigDecimal(1));

Amit4
Contributor III
Contributor III
Author

@Shicong_Hong 

Thanks it worked well but there is another problem, The whole case is I have to insert the new record into the map table if it's already not there which is coming from Stage table. If there are multiple new records then it is giving same ID for all records. This we need to handle. Below screenshot you can see.

Max(ID) in Map table is 248 so it Inserted 249, but 3 new records came all got assigned the same, it should go as 249, 250, 251.

 

Amit4_1-1718358468573.png

 

Amit4
Contributor III
Contributor III
Author

I used the Numeric sequence is variable an and used in map.

Var.varIncrementedID = context.MaxID.add(new BigDecimal(Numeric.sequence("s1", 1, 1)))

Amit4_0-1718464532910.png

Now it's working as expected.

Thanks,

Amit