One Star

Dynamic Variable

I am new to Talend. Can someone explain me the steps involved in passing a dynamic variable to a query using talend. From step 1 to step N if possible. I am not able to do so. I basically want to use a date pulled out from one table and use that in a query. The query should be able to dynamically carry the variable value as the date may change in the parent table. Please help
Seventeen Stars

Re: Dynamic Variable

Easy to do:
2 ways to do: use context variables or the globalMap (only accessible within the job).
1. create a context variable (e.g. country as String type)
2. add the database component to your job and add the query (at first with a fix value)
"select ID, sum(revenue) from country_rev where country_name='USA'"
3. now change the query to use your variable:
"select ID, sum(revenue) from country_rev where country_name='" + + "'"
4. If you have your value in the globalMap here is the necessary query:
"select ID, sum(revenue) from country_rev where country_name='" + globalMap.get("country") + "'"
Talend only supports plain text replacements for the query in input components.
You can also consider using the *row components, these comps supports prepared statement parameters.
One Star

Re: Dynamic Variable

How to pass the value of the variable to the global variable?????