Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
bob_lemley
Contributor II
Contributor II

tFileOutput not recognizing global variable

I have a job that does this tDBInput --> TWriteJSONField --> tJavaRow --> tFileOutputDelimited --> tJavaRow.

I the first tJavaRow I set a global variable for the file name. I also print out the variable so I can confirm it is correct.

I also have a print line in the second tJavaRow that again prints out the variable so I can confirm it is still set.

But when I use the global variable in the tFileOutputDelimited it comes across as null. If I set the global variable to a default value that default value is used in the tFileOutputDelimited filename so I know it can read the variable.

Is there a reason the tFileOutputDelimited cannot see the global variable value when it is changed?

It may be a logic thing with Talend I am not understanding. I asked Talend support and they sent me the canned response on context variables. I tried using a context variable but got the same results.

Labels (2)
2 Replies
Anonymous
Not applicable

Hi

Please read this documentation page to learn the code generated mode. In this case, tFileOutputDelimited is initialized before tJavaRow, so change the job design as below, tFileOutputDelimited will have the value of global variable.

tDBInput --> TWriteJSONField --> tJavaRow -->tFlowToIterate--iterate--tFixedFlowInput--main--> tFileOutputDelimited -->

 

Regards

Shong

bob_lemley
Contributor II
Contributor II
Author

Thank you, this worked for me. And thanks for the link, it had some very useful information.