Talend: query database with strings / parameters already defined

How to execute a query in my database (using tOracleInput ), for example Select , and use rows that are already defined as parameters in other components, for example in 'tFlowToIterate'?

For example: " SELECT * from TABLE_X, where FIELD_X =?; "

My '?' is a variable that comes from my component tFlowToIterate (foo). I have already tried with (String) globalMap.get ("foo") and other similar forms ...

thanks

[Talend Open Studio for data integration v5.3.1; DB: Oracle]

+4
source share
2 answers

You answered yourself. The component tOracleInputaccepts the request as a parameter. This is a very boring java line, nothing more, nothing less. This means that if you want to use the globalMap element inside the request, you just need to concatenate the java String. Something like that:

"SELECT * from TABLE_X where FIELD_X='" + (String)globalMap.get("foo") + "'"

but this one will not work (look carefully at the quotes):

"SELECT * from TABLE_X where FIELD_X='(String)globalMap.get("foo")'"

Keep in mind that if you write a query using string concatenation and external vars, the query editor is likely going to mess up all the quotes by creating a broken query.

"*" , tOracleInput. Talend , . , TABLE_X, ETL .

:

  • *
  • "Guess Schema", .
  • "Guess Query", SELECT
  • (.. WHERE...)
+7

.

, :

"SELECT *
FROM TABLE_X
WHERE FIELD_X = '" + (String)globalMap.get("foo") + "'"
+3

All Articles