Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I'm pretty new to Talend and am working in 5.6 and need advice re global variables.
I have inherited a job which needs changing. The Main Job Calls a Sub Job (Sub Job 1) which does some processing and writes data to several Oracle tables, one of which I need to capture the number of records written to so that I can then pass this figure to the next Sub Job (Sub Job 2) that the Main Job calls upon Sub Job 1 completing successfully, where it is then added to another Oracle table.
The approach I though to take was to create a global variable (recordCounter) in the Main Job and initialize this to 0. Then in Sub Job 1 get the count of records the job adds to the table put this value in the global recordCounter variable the when Sub Job 2 runs read the new value in the global recordCounter. However, when I call globalMap.put("recordCounter", "1"); in a tjava component in Sub Job 1 it does not update the global recordCounter variable declared in the Main Job; the value remains as 0 as demonstarted when I write it out to the console in the Main Job. Also when I try to read the value of the global recordCounter variable in Sub Job 2 ((String)globalMap.get("recordCounter") it reports the value as null. So my question is how to I mange to pass values back and forth to global variables between child an master jobs.
Also related to this, which is the next step of my problem is how do I get the number of records a tmap component has inserted into an Oracle table; is there a component for this? My tmap3 component is inseting records into my Failure_Messages oracle table via a tOracleCompnnent.
Any help and advice would be much appreciated.
@fdenis , thank you so much for this. I'll crack on with it on Monday, when I'm back at work and let you know how I get on.