[resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

One Star

[resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

After an insert in a table in a SQLServer Database, I want to display the number of records inserted
So I use the global variable ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))
and I get Null as result.
I have check in the table the row is inserted!
Where is my misstake?
Thanks

Accepted Solutions
Community Manager

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Hi
The variable have to be used in the next subjob rather than child job, so change the job as seen below, you should be able to get the value of the global variable.
For example:
tFileFetch
   |
onsubjobok
   |
your main processing---tMssqlOutput_1
  |
onsubjobok
   |
tFixedFlowInput--main--tLogRow
on tFixedFlowInput, you get the number of lines which has been updated/inserted/deleted on tMssqlOutput, to do it: define one column called it nb_inserted, and set its values as:
((Integer)globalMap.get("tMSSqlOutput_1_NB_LINE_INSERTED"))
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Hi 
Can you please upload a screenshot of job? I think there might be a job design issue here.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Below the screenshot of the job:



((Integer)globalMap.get("tMSSqlOutput_1_NB_LINE_UPDATED"))  are in the tMap_3 et tMap_4 components
One Star

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

No idea?????Smiley Sad
Community Manager

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Hi 
It is not a bug, this kind of global variable should be used in next subjob, if you look into the generated code of job, you will see the the code ((Integer)globalMap.get("tMSSqlOutput_1_NB_LINE_UPDATED")) on tMap_3 is executed before putting value to the global variable in the end part of tMssqlOutput, so you need to change the job design, eg:
....tMSSQLOutput--tHashOutput
   |
onsubjobok
   |
tHashInput--main--tMap_3....

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

now I have the following main job:



and 2 subjobs :





but I don't see the number of rows inserted or updated!!

Another ideas??

Thanks
One Star

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Now I have the fillowing job:

the subjob:



But I have many error in the subjob:


Any ideas??
Thanks
Didier
Community Manager

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Hi
The variable have to be used in the next subjob rather than child job, so change the job as seen below, you should be able to get the value of the global variable.
For example:
tFileFetch
   |
onsubjobok
   |
your main processing---tMssqlOutput_1
  |
onsubjobok
   |
tFixedFlowInput--main--tLogRow
on tFixedFlowInput, you get the number of lines which has been updated/inserted/deleted on tMssqlOutput, to do it: define one column called it nb_inserted, and set its values as:
((Integer)globalMap.get("tMSSqlOutput_1_NB_LINE_INSERTED"))
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] ((Integer)globalMap.get("tMSSqlOutput_2_NB_LINE_INSERTED"))

Thanks Shong
easier and it works!