Six Stars

store the dynamic values in context variable

I am beginner in Talend , So need help 

 

From the source I have ID column and I need to store the max value  of ID into the context variable and use it in the query in the source in next run like as below 

where clause as  where ID > "+context.Max_ID+" 

 

Please guide me how I can implement this

4 REPLIES
Forteen Stars TRF
Forteen Stars

Re: store the dynamic values in context variable

Have a look to tContexDump and tContextLoad components

TRF
Six Stars

Re: store the dynamic values in context variable

Could you pls help me in steps

Forteen Stars TRF
Forteen Stars

Re: store the dynamic values in context variable

Suppose you have a property file which contains the last Max_ID you've queried:

Key;Value
Max_ID;100

When the job starts, you can get the content from this file to populate your Max_ID context variable using tFileInputDelimited + tContextLoad components:

Capture.PNG

Now you can use the current Max_ID value in your query where clause.

From the result, you have to retrieve the new max value to update the Max_ID variable (using a tJavaRow or something else).

Finally, use a tContextDump to dump all the context variables, tFilterRow to keep only the key "Max_ID" and tFileOutputDelimited to overwrite the initial property file with the new Max_ID value:

Capture.PNG


TRF
Forteen Stars TRF
Forteen Stars

Re: store the dynamic values in context variable

@Karuetl did this help you? If so, thank's to mark you case as Solved (Kudos also accepted)


TRF