How to detect "No Rows"

I am using the "tMap" component to join together several hash tables.
How can I detect that the join of the hash tables has resulted in "no rows?"
I would like to generate an e-mail when this happens.
Thanks
Peter
3 REPLIES
Community Manager

Re: How to detect "No Rows"

Hi Peter
Link the output table from tMap to a tJavaFlex component, and use runIf connector to trigger the email component if the result of join is 0. For example:
....tMap--main--tJavaFlex
|
runIf
|
tSendMail
in the begin part of tJavaFlex, define a counter.
int nb_line=0;
in the main part of tJavaFlex, the counter will +1 if there comes an input row.
nb_line++;
in the end part of tJavaFlex, check the number of the counter if it is great than 0 or not, and store the result to a global variable for used later.
if(nb_line==0){
globalMap.put("isNoRow",true);
}else{
globalMap.put("isNoRow",false);
}
Set the condition of runIf with the global varaible,
(Boolean)globalMap.get('isNoRow")
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: How to detect "No Rows"

Hi Peter,
- I have one more small Idea, Use a context variable as cnt and set its default value to 0.
- Use simple tjavarow at the output for that join and put following code
context.cnt = context.cnt +1;
Connect tSendMail component from tjavarow with condition RunIf having condition context.cnt == 0;

Check sample screenshot, you will get an idea for this.
Vaibhav

Re: How to detect "No Rows"

Thanks for the ideas guys. I will try both.
Thanks!!!
Peter