Capture table name after it's been created

Four Stars

Capture table name after it's been created

I'm new to Talend.  I have a situation where I need to build a temporary SQL table with this naming convention:

xxxxxx_YYMMDD_HHMMSS.

 

I haven't been successful at creating a context variable containing YYMMDD_HHMMSS, so I took another path and just created a table with 

"xxxxxx_"+TalendDate.getDate("YYMMdd_HHmmss")" in the table name for my chosen DB connector.

 

I do need to reference this table elsewhere in my job.  How can I retrieve that table name for use in subsequent/child jobs?

 

Thanks for any help you could give.

 

 

Employee

Re: Capture table name after it's been created

Hi,

 

    Since you need to refer the data in other areas of the job, you will have to go for context variable as it is the most easy way to do it.

 

    You can assign the same values to a context variable by adding a tjava and assigning like below.

 

context.temp_table_name="xxxxxx_"+TalendDate.getDate("YYMMdd_HHmmss")" ;

 

    If you are facing any issue while doing it, please share the screen shots of the job flow, component screenshot where error is coming and we can take it from there.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending their time for your query. If your query is answered, please mark the topic as resolved :-)
Eight Stars

Re: Capture table name after it's been created

Hi @nikhilthampi,

Greetings of the day,

I have a query, should tjava code(context variable code)be invoked before or after the temp table is created ???

How exactly should the flow be?? And if the context variable is being used almost everywhere in the Job then should all the subjobs also be connected to the major flow??

Thanks,

Ankit

Employee

Re: Capture table name after it's been created

Hi Ankit,

 

     Since Context variable is holding the database table name, it has to store the value before temp table creation.

 

     If you want to transfer context variables to sub job, its possible. There is an option to transfer the context variables of parent job to child job.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending their time for your query. If your query is answered, please mark the topic as resolved :-)
Four Stars

Re: Capture table name after it's been created

I'm having difficulty figuring out exactly how to set the context variable.  I've scoured the boards for an answer but I still can't get my variables to carry through.  

 

I'm simply copying a table from SQL server to Postgres.  I'm creating a temp table to load in Postgres, and naming it xxxxx_YYMMDD_HHMMSS to maintain a separate table before updating the main table.  What I can't figure out is where to put the tJava component for the context variable creation, and then how to display the value of the context variable.  

 

My job is simple:   DBInput --> tMap --> DBOutput.   I'll create a subsequent step to merge the new temp table with existing production data, but I need to propagate that table name so I can drop it at the end of my job. 

 

Hope this helps.  I appreciate any help you could give.

 

 

Highlighted
Employee

Re: Capture table name after it's been created

Hi,

 

     The best place to always start searching is the Talend help document site and Talend community.

 

     Could you please go through the below link to understand the concept of Context variables and sample scenarios?

 

https://help.talend.com/reader/NCvLSgL85zqYq7YwX3T3jQ/xbhyQKORQNX5V8yw8WAb8w

 

     Once you are familiar with the concept, you can create the context variable for your specific use case. If you are facing any issues in job, please feel free to share your job flow screenshots and component screenshots of how you are assigning the context variables and we can help you. In this way, you will get a solid foundation about the context variables of Talend.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending their time for your query. If your query is answered, please mark the topic as resolved :-)

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.