How to use the output of a query as input to anoth

2019-07-30 18:05发布

问题:

I am new to Talend, but I want to have a job similar to this: in a tMysqlInput, make a select statement that returns a single row with a single column and then use that value in a tMongoDBInput query to get multiple documents.
How can I do that in a single job, as I am unable to link tMysqlInput to tMongoDBInput with a row(Main)?

回答1:

You can do this :

tMysqlInput -- main -- tFlowToIterate -- Iterate -- tMongoDBInput -- tMap -- etc

The input flow of tFlowToIterate gets converted to global variables, so you can use it in your mongoDB component query by referencing the global variable : (String)globalMap.get("rowX.MyColumn")

rowX is the name of tFlowToIterate's incoming main row, and MyColumn is the column name. Make sure to cast the variable to the appropriate java type.