Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tMap Join, how can I get total no of rows after the join?

Hi,
I am joining 3 tables in tMap (1 main + 2 lookup tables) and the target table needs to be updated. 
One of the column in the target table is Total number of rows joined. 
When TMap writes to Target Table, it is processed row by row.  While writing to Target table I need to write total no. of rows joined also as one of the target column.
How can I acheive this?  When it is getting written in the target it is row-by-row... but at the same time one of the column should be updated with the total-no-of matching rows.... I am not sure how to do this..  Any help please?

Labels (2)
2 Replies
Anonymous
Not applicable
Author

Hi,
I think you do this in 2 step:
- update row by row the target table
- add an aggregation and update the target table
designed like this :
Source + lookup ==> tMap --> tDBOutput (update) -->tAggregateRow --> tDBOutput (update)

Jeremie
willm1
Creator
Creator

One easy way would be to use the DB component's NB_LINE global variable in an update statement (in a DBRow component) after loading the target table. 
"Update table set field = " + ((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_INSERTED")) + " where loadcondition = xyz"
You can also update with updated rows, for rows that existed before: ((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_UPDATED"))
You get the global variables by Ctrl + Spacebar




oading the target table, and update the target table's count column with the NB_LINE from the tMap. NB_LINE