Passing context variables from subjob to job parent always null value

One Star

Passing context variables from subjob to job parent always null value

Hello all,
I've read all entries in forum related with those topics, but I'm not able to solve this problem.
This are other options that I've tried:
- use of tSetGlobalVar
- use of tContextDump, SynchronizeContext()
- use for set/retrieve values of context vars with context.var_name=value , globalMap.put("var_name",value); and globalMap.get("var_name")
I also defined a context variables, and in every job, I've used them.

This is the pics from my jobs and the result of execution.

Starting job testParent at 10:46 03/02/2011.
connecting to socket on port 3419
connected
ON TEST: context.entidad_id_remota= srUsS8
srUsS8|dyPSBb
28PAvp|AuC6PN
DIzm6c|rO6RDs
qhr8ZT|rqxPtg
ON TEST PARENT: globalMap.get('entidad_id_remota')= null
disconnected
Job testParent ended at 10:46 03/02/2011.

I really need help, please.
Thanks in advance.
One Star

Re: Passing context variables from subjob to job parent always null value

child/subjob:
generate a data flow with tRowGenerator, use it as a input link in a tBufferOutput
parent/mainjob:
the output link/data flow of your tRunJob calling that child/subjob now contains the passed data
Regards,
Lordan
One Star

Re: Passing context variables from subjob to job parent always null value

Hi Lordan,
thanks for your response, but this is not that I'm looking for.
That I need is to retrieve values not from a data flow, but an variable.
Thanks anyway.
One Star

Re: Passing context variables from subjob to job parent always null value

that is why you need the tRowGenerator!
for example you need to pass the context.myData value which is a String.
So you add a column 'myData' in the tRowGenerator schema, set the num row to 1
and enters the context.myData as value for that column...-> screenshot
One Star

Re: Passing context variables from subjob to job parent always null value

Yes, it's wonderfull if I can be made this from the parent job, but the problem is the same.... I can't retrieve the value in the context var, always null.
The josbs that I've made is an example.
The real need I have and the reason for that I need it, it's because the context var value will be retrieved from more than one parent jobs.
The idea is make a child job that instantiate the context var, and from other parent jobs, retrieve its value.
Thanks very much for your responses.
One Star

Re: Passing context variables from subjob to job parent always null value

I'm very new to Talend and am still trying to get my head around "thinking in Talend". That is trying to figure out which components and arrangements are best to accomplish a particular goal. The problem I'm having is passing a context variable to another component in the same job. What I want to do is create a date dimension. I've set up a loop to generate a list of numbers. These numbers are passed to a tJava and then tJavaRow where each number is a day added to a java Calendar to increment days. I then (using Java) create all the attributes for that day. I pass these attributes through a tMap and on to a database table. This all works fine.
The next step in the evolution of this job is to look at the existing database table and only insert a new day record if it does not already exist in the table. I added a second database connection (tInformixInput) and added SQL the queries for the day record in question.
"select date_dimension_key, full_date_name from date_dimension where date = date('" + context.strCurrDay + "')"
If I don't default the strCurrDay value my SQL always crashes because it's null. If I set a default value, that value is always used and not updated. BTW, the context variable is updated in the tJavaRow with each iteration of the loop. I have a tLogRow component which is showing me the context.strCurrDay from the tJavaRow component and the result of the SQL query. tJavaRow is indeed stepping through the days, but the database connection is not. It is not getting the new value(s) for the strCurrDay.
What am I doing wrong? I have some screen shots, but don't now how to attach them here.
One Star

Re: Passing context variables from subjob to job parent always null value

Yes, it's wonderfull if I can be made this from the parent job, but the problem is the same.... I can't retrieve the value in the context var, always null.
The josbs that I've made is an example.
The real need I have and the reason for that I need it, it's because the context var value will be retrieved from more than one parent jobs.
The idea is make a child job that instantiate the context var, and from other parent jobs, retrieve its value.
Thanks very much for your responses.

I must admitt I do not get your problem with that solution....
Look at the screenshots I attached.
You will see, the child job passes its context variables to the bufferOutput.
The parent job gets this data.
Put this link into a tJavaRow and modifiy the parents context vars with that data and you are done....
Any parentJob calling that childJob in this way would get the modified context vars
Of course there are some issues with that simple jobs I prepared, the modifying of the context vars needs some more work
and with many context vars you should consider to use tContextDump, put the fata from it into a tJavaRow and modify each value in that tJavaRow
depending on the key and so on...but the way of passing the context var from one childJob to several parent jobs is always the same....
One Star

Re: Passing context variables from subjob to job parent always null value

I'm very new to Talend and am still trying to get my head around "thinking in Talend". That is trying to figure out which components and arrangements are best to accomplish a particular goal. The problem I'm having is passing a context variable to another component in the same job. What I want to do is create a date dimension. I've set up a loop to generate a list of numbers. These numbers are passed to a tJava and then tJavaRow where each number is a day added to a java Calendar to increment days. I then (using Java) create all the attributes for that day. I pass these attributes through a tMap and on to a database table. This all works fine.
The next step in the evolution of this job is to look at the existing database table and only insert a new day record if it does not already exist in the table. I added a second database connection (tInformixInput) and added SQL the queries for the day record in question.
"select date_dimension_key, full_date_name from date_dimension where date = date('" + context.strCurrDay + "')"
If I don't default the strCurrDay value my SQL always crashes because it's null. If I set a default value, that value is always used and not updated. BTW, the context variable is updated in the tJavaRow with each iteration of the loop. I have a tLogRow component which is showing me the context.strCurrDay from the tJavaRow component and the result of the SQL query. tJavaRow is indeed stepping through the days, but the database connection is not. It is not getting the new value(s) for the strCurrDay.
What am I doing wrong? I have some screen shots, but don't now how to attach them here.

you should create a new topic for your issue 'cause it is not related to this one.
Under the text box you will find a box 'Image Upload' and a dropdown menu inside it, select the number of screenshots you would like to attach...
Seventeen Stars

Re: Passing context variables from subjob to job parent always null value

hi,
try and change in parent job the trigger "onsubjob ok" by a dataflow "main" !
regards
laurent
ps : use component setGlobalVar instead of java code
One Star

Re: Passing context variables from subjob to job parent always null value

Hi Lordan,
sorry to be late in response to you Smiley Sad
I've do it as you recommend and works ok, but I don't get the data from other flows, because when this end and the data is on parent job, the other flows returns 0 rows. If I execute this jobs alone returns data.
It seems like if executes first one flow, the other flows are "out of time" and returns nothing.
There isn't any parallell execution of jobs from the same data sources.
Thanks very much for your time.
One Star

Re: Passing context variables from subjob to job parent always null value

Hi kzone,
I've done it as you say, but the same result.
Furthermore, the sequence of execution isn't good; first executes the tJava_1 with null value in the context var.
Thanks anyway.