Combining Multiple rows returned by a SQL statement into a string

One Star

Combining Multiple rows returned by a SQL statement into a string

I have a tMySQLInput that returns multiple rows. In each of these rows is information that when combined will create the where clause of a SQL statement. How can I combine the multiple rows returned from the SQL statement into one string.
Thank You
Scott
Community Manager

Re: Combining Multiple rows returned by a SQL statement into a string

Hi Scott
You can concatenate all rows on a tJavaFlex component, for example:
tMysqlInput--row1--tJavaFlex
in the begin part of tJavaFlex, define a empty string, eg:
String s="";
in the main part of tJavaFle, concatenate all the rows returned from tMysqlInput, for example:
if(s.equals(""){
s=row1.name;
}else{
s=s+";"+row1.name;
}
//name is a column name on tMysqlInput;
in the end part of tJavaFlex, put the string to a global variable so that you can use it on other component later. For example:
globalMap.put("key", name);

Let me know if you still have problems!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business