How to use context parameter in sql?


I have defined one context parameter: search_id.

Now there is one component tMySqlInput in my job.

I need to search some data by below sql:

"SELECT count(1) FROM business WHERE business_id=?"
In the "where clause" need to use context: search_id.
Can you help to give me any solutions? Thanks a lot.
fengjianquan_1's picture
Joined: Oct 8 2015 - 7:18pm
Last seen: 5 years 6 months ago

1 Answer:


Hi Ted,

unfortunately using bind variables is only allowed in row components and not input components:

You can still concatenate the context variable to the query string as you would do in Java, for example:

"SELECT count(1) FROM business WHERE business_id = " + context.search_id

I'm assuming search_id is a number so no need to surround it with single quotes. Otherwise it would be:

"SELECT count(1) FROM business WHERE business_id = '" + context.search_id + "'"

See this screenshot for an example:

Screenshot of Talend showing tPostgresqlInput component with query using the context variable.

Please accept and/or up-vote the answer if you think it's useful, thanks!


kkumlien's picture
Joined: Jan 22 2015 - 4:36am
Last seen: 2 weeks 2 days ago