Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to Use output of tjavarow in tmap variable expression in main job

Hi All,

 

I have a requirement of implementing Incremental load for a target table in Mysql DB.

My primary Key is a AlphaNumeric i.e W00000001,W00000002,W00000003 etc.,to achieve this i am using 

 

Numeric.sequence("s1",1,1).toString() in tmap var section

 

and used the below code in output component of tmap(attaching the screenshot as well)

StringHandling.LEN(Var.V_SEQ)<8?
"W"+StringHandling.STR('0',8-StringHandling.LEN(Var.V_SEQ))+Var.V_SEQ:"W"+Var.V_SEQ 

0683p000009M4j8.png

 

The process i have followed is to get the max of Primary Key  from target table and auto increment  .

 

To do so i have used tDBinput(Mysql) >Main>tJavarow>tlogrow(for testing purpose)

tDBinput(Mysql)  = "SELECT max(KEY ) as BOOKING_KEY FROM `TableName`"  and created context (attached the screenshot)

0683p000009M4jD.png

And in tjavarow i have use the below code 

 

context.BOOKING_KEY=input_row.BOOKING_KEY;

context.BOOKING_KEY_NEXT=Integer.valueOf((context.BOOKING_KEY).replaceAll("W",""))+1;

System.out.println(context.BOOKING_KEY_NEXT);

 

so the input and output of the job will be W00078385 and 78386.

 

Here my ask from community is how this output can be used in var section of tmap  Numeric.sequence("s1",1,1).toString()  in the main job so that the next time the PK will start from max number of target table 

 

Labels (3)
4 Replies
manodwhb
Champion II
Champion II

@pabburi ,you do all the things in tmap and load into context by using tContextload.

 

 

Anonymous
Not applicable
Author

Hi @manodwhb ,

 

I am not sure on how to do this in tmap,could you please elaborate? 

manodwhb
Champion II
Champion II

@pabburi ,check the below is the example to do with tmap. you change as per your requirement.

 

0683p000009M4cY.png0683p000009M4jI.png0683p000009M4Yu.png

Anonymous
Not applicable
Author

Hi @manodwhb ,

 

As mentioned in the beginning, I would like to know how can i use the output of tjavarow in the tmap.

 

Posting my job design for reference.I have use the output of tjavarow which is an number in the tmap sequence definition i.e 

Numeric.sequence("s1",1,1)

have 3 parameters:

  • s1 - Name could be any
  • start value - this is what all above about
  • increment, default 1

 

0683p000009M4dL.png0683p000009M4kZ.png