Load Variable from Database and assign to Context variable

Five Stars

Load Variable from Database and assign to Context variable

I tried to Load value from database and set in a context variable.

I have a table DatabaseConfig and two column (key,value).

Created two context in my job as key and value.

When i try to run the job, the output i am receiving is null


Accepted Solutions
Nine Stars

Re: Load Variable from Database and assign to Context variable

Hi Dinesh,

 

Are you looking read context values from DB and assign to context variables in job?

 

DB ContextValues.PNG

 

For this you need to define context variable name is same as key value in database.

Here key value is day, so you need to define context variable name as day. Then tContextLoad will assign value (monday) to context "day" 

 

DB ContextValues1.PNG

 

Hope this helps you.

 

Regards,

 

Veeru Boppudi

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen Stars

Re: Load Variable from Database and assign to Context variable

Hi,

Can you share your job design?

At least, which components are you using?


TRF
Five Stars

Re: Load Variable from Database and assign to Context variable

I attached my job design.

Sixteen Stars TRF
Sixteen Stars

Re: Load Variable from Database and assign to Context variable

It should work.

Double check variables name in your tJava component.

Also verify columns name in SQL schema are aligned with context variables name defined for the job.

 


TRF
Five Stars

Re: Load Variable from Database and assign to Context variable

I have attached 4 files.

-> Database table

-> Context variable for my Job

-> SQL Input connection page

-> Page where to load context detail from DB.

Could you check this and let me know for any further information

Sixteen Stars TRF
Sixteen Stars

Re: Load Variable from Database and assign to Context variable

What's in your tJava component?

What's in your tMSSqlInput component? Should have 2 fields, not 3 as there in the table.


TRF
Five Stars

Re: Load Variable from Database and assign to Context variable

I am getting output as :

 

Starting job DatabaseJob at 16:57 30/03/2018.

[statistics] connecting to socket on port 3429
[statistics] connected
Implicit_Context_Context set key "days" with value "monday"
Warning: Parameter "days" is a new parameter of Implicit_Context_Context
Warning: Parameter "Key" has not been set by Implicit_Context_Context
Warning: Parameter "Value" has not been set by Implicit_Context_Context
tContextLoad_4 set key "days" with value "monday"
hi


DatabaseJob

[statistics] disconnected
Job DatabaseJob ended at 16:57 30/03/2018. [exit code=0]

 

 

tJava i am printing :

 

System.out.println("hi");

System.out.println(context.Key);
System.out.println(context.Value);
System.out.println(jobName);

Five Stars

Re: Load Variable from Database and assign to Context variable

databasepage -> this jpg which i attached is tMSSqlInput component.

Ok i changed my Database table to two columns. 

Nine Stars

Re: Load Variable from Database and assign to Context variable

Hi Dinesh,

 

Are you looking read context values from DB and assign to context variables in job?

 

DB ContextValues.PNG

 

For this you need to define context variable name is same as key value in database.

Here key value is day, so you need to define context variable name as day. Then tContextLoad will assign value (monday) to context "day" 

 

DB ContextValues1.PNG

 

Hope this helps you.

 

Regards,

 

Veeru Boppudi

View solution in original post

Highlighted
Five Stars

Re: Load Variable from Database and assign to Context variable

what if i want to read values from the queries and store them into globalmap variables??

ex: If i am using tmssqlinput and query is:

"select col1 from table1;

select col2 from table2;

"

Note: for the above query i am getting value for col1 only, col2 is NULL even after setting the additional jdbs parameters with "allowMultiQueries=true"

 

Please help

 

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

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog