assign tMSSqlRow value to context variable?

Five Stars

assign tMSSqlRow value to context variable?

Hi,

 

 

how to assign tMSSqlRow value to context variable ?

 

Below is my query is written in tMSSqlRow_2. Need to read the value from tMSSqlRow_2 and assign to context variable. how to achieve this?  Please help

 

Query :

"
begin
declare
@srcid int,
@sessionid int;

select @srcid=srcid from dbo.src_tbl where src_name='xxx';

select sessionid from session_tbl where srcid=@srcid and loaddate='2011-12-20'
end
"

 

 

Additional info:

session_tble structure:
sessionid int IDENTITY(-3333333,1) not null ,
srcid int,
loaddate date

 

src_tbl structure:

src_id int,
src_name varchar(500)

 

Context:

Name          Type    Value (default)

SessionID    Int        -9999999

 

i have followed this :

tMSSqlConnection -->tMSSqlRow_1  --OnComponentOK---> tMSSqlRow_2  ---main--->tJavaRow-->tLogRow 

 

i have written above code in tMSSqlRow_2, in tMSSqlRow_1  ("sessionid")  is getting populated.

 

When i run job it is writtening null.

 

Please help.

 

 

Thanks

Sixteen Stars TRF
Sixteen Stars

Re: assign tMSSqlRow value to context variable?

Hi,
What's in tJavaRow?

TRF
Community Manager

Re: assign tMSSqlRow value to context variable?

Can I ask why you are using the tMSSqlRow for this? From what I have seen of your problem, it would be a lot more straight forward to use the tMSSqlInput to read the data and the tMSSqlOutput to write the data.

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 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog