Six Stars

how to save a value from table to context variable

Hi,

 

I have a value in my table as 

 

name

xyz

 

how to store the value xyz to context variable. so that we can use it for further use.

1 ACCEPTED SOLUTION

Accepted Solutions
Five Stars

Re: how to save a value from table to context variable

use below code in tJavarow:

 

context.var = context.var+row4.newColumn ;

Regards
Aashish
9 REPLIES
Twelve Stars

Re: how to save a value from table to context variable

@Darmesh,you can load to context using tContextLoad and check the below link to more about tContextLoad.

https://help.talend.com/reader/wDRBNUuxk629sNcI0dNYaA/xH2TyYr_AmQnKwOYlqVCvA

Manohar B
Five Stars

Re: how to save a value from table to context variable

With the help of tjavarow component, you can do so.

So, your job would be like :

tmssqlinput-->tjavarow

In tjavarow write below code.

 

context.var = input_row.name;

 

Regards
Aashish
Six Stars

Re: how to save a value from table to context variable

@aashish

first i have created context variable as var and did not enter anything in value column.

But it is not loading anything.a.PNGb.PNG

Five Stars

Re: how to save a value from table to context variable

@Darmesh you should write input_row.column_name rather than row4.column_name.

Regards
Aashish
Six Stars

Re: how to save a value from table to context variable

@aashish

still i am getting null value.

 

a.PNGb.PNGc.PNG

Five Stars

Re: how to save a value from table to context variable

System.out.println(context.var);

Regards
Aashish
Forteen Stars TRF
Forteen Stars

Re: how to save a value from table to context variable

Setting a value to a context variable will not change what you can see into the Context tab, it changes only the current value for the runing job.


TRF
Six Stars

Re: how to save a value from table to context variable

@aashish @TRF

I got the result. But when i am passing that context var vaule to tmap. i am getting only "Quarterly Estimates" and not the variable value.

 

a.PNG

Five Stars

Re: how to save a value from table to context variable

use below code in tJavarow:

 

context.var = context.var+row4.newColumn ;

Regards
Aashish