set a context variable and call it in next component

Highlighted
Six Stars

set a context variable and call it in next component

Hi I need to assign a context variable while the job is running and use the same context variable in the subsequent component. ,

 

please check the below flow for what my requirement is , tfilelist is the first component 

 

tfilelist--> tinputfiledelimited -->tjava --> tmysqloutput

flow.png

 

 

can someone help me with how I shall proceed ,

 


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: set a context variable and call it in next component

You can make the substitution when needed or use tJavaRow in your case (because of tJava behaviour described previously)


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: set a context variable and call it in next component

tJava component is executed 1rst and only once for the subjob, so tJavaRow is better in this case.

The question is, why do you want to use a context variable as soon as you have a standard global variable which contains what you want?


TRF
Six Stars

Re: set a context variable and call it in next component

being new to Talend, what i have understood is standard variable i.e. ((String)globalMap.get("tFileList_1_CURRENT_FILE")); will return me with the file name and extention. i.e if the file name is abc.txt it will return abc.txt, what i need is a table to be created with the name abc , not abc.tc , with the standard variable the table is getting created but with the name "abc.txt".

 

so i thought doing a substring on the name and storing that in a variable and later using that for table name

Fifteen Stars TRF
Fifteen Stars

Re: set a context variable and call it in next component

You can make the substitution when needed or use tJavaRow in your case (because of tJava behaviour described previously)


TRF
Six Stars

Re: set a context variable and call it in next component

the substitution can be made as follows :

 

StringHandling.CHANGE(((String)globalMap.get("tFileList_1_CURRENT_FILE")),".txt","")

 

this worked for me as I directly put the above code in the table field.

 

reference on StringHandling Routines:

https://help.talend.com/reader/mhqCkTBnin7IXmJBUJoocQ/5qboCU~1NO4j7aF9JtCWNg

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads