if query returns a recordset, do this, otherwise do that

One Star

if query returns a recordset, do this, otherwise do that

hey all, need a lil help on a fairly simple task. here's the scenario:
i have two tables, ListAddress and RepListResult. i need to pull all records from ListAddress, which I will then iterate over. for each returned row from ListAddress, i need to run a query that uses the ListAddress row's 'AddressId' column; this query will return any record from RepListResult that has a matching 'AddressId'.
so, all of that above i have been abel to do, but here's where i'm stuck now: if the cross-check query returns even one row (i.e. its recordset is not null nor empty), i do not want to do anything at all. if there are no rows returned, i want to then take the original row's data from the first ListAddress query and write it to a CSV file.
i've attached a screenshot of my job thus far, but would greatly appreciate any input on how i can accomplish the end of the job. also, any links to documentation on how to use components, particularly examples, are very welcome. thanks guys!
One Star

Re: if query returns a recordset, do this, otherwise do that

i don't know where the image went, but her's a link to it: http://i.imgur.com/8cZdl.png
Community Manager

Re: if query returns a recordset, do this, otherwise do that

Hi
Which database type? Mysql? Oracle? or others?
There is a global variable like ((Integer)globalMap.get("tMysqlInput_2_NB_LINE")), we use normally this global variable to check how many lines are returned by the query. For example:
tMysqlInput_1--row1-->tFlowToIterate---->iterate-->tMysqlInput_2--->tLogRow---runIf---tFixedFlowInput--main--tFileOutputDelimited
on tMysqlInput_1:
select AddressId from ListAddress
on tMysqlInput_2:
run a query that uses the ListAddress row's 'AddressId' column as you mentioned.
Set the condition of RunIf:
((Integer)globalMap.get("tMysqlInput_2_NB_LINE"))==0
on tFixedFowInput, generate one line with one column on the schema,
key:value
AddressIdSmiley SadInteger)globalMap.get("row1. AddressId")

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

Re: if query returns a recordset, do this, otherwise do that

thank you very much, @shong, that was exactly the help i needed. apparently, my profile is still unable to post images and such, so here's a link to a screenshot of the finished job.
screenshots:
http://imgur.com/a/f17PA#0