One Star

Dynamic Database Connection using Context

Hi All,
I am new to Talend tool. I try to use dynamic database connection using context. I added all the connection details in the context variable and inside job i used tOracleInput component, inside the query box i added my sql query and added the context variables in the corresponding controls and try to run the job. but getting an error as " table or view doesn't exists"
Please find the attached screenshot
Please kindly do the needful
Waiting for answer
Thanks
Madhu
6 REPLIES
One Star

Re: Dynamic Database Connection using Context

If i add an schema name before table name then it working fine (i.e. select * from db.employee). but i dont want to add the schema name because my qa database schema is different so i need to do it dynamically
Please suggest me how to proceed
Thanks
Madhu
Four Stars

Re: Dynamic Database Connection using Context

Hi Madhu,
Screenshot is not clear. Your error is simply says that the table or view which is referred in the query does not exists. Check your query again with the database connection. It is good to use connection component before using input component.
Regarding dynamic database connection, whether the connection parameters are selected from property file which is changing continuously based on some value? from where and how this dynamic value is changing?
Vaibhav
One Star

Re: Dynamic Database Connection using Context

Hi sanvaibhav,
Please find the screenshot.
If i add an schema name before table name then it working fine (i.e. select * from db.employee).
but i dont want to add the schema name because my qa database schema is different so i need to do it dynamically
Four Stars

Re: Dynamic Database Connection using Context

Hi Madhu,
Concept of dynamic means - a query or a result set which changes run-time based on some other input value. Schema name is must, if you don't want to hard code it, how you are planning to embed in the query?
Thanks
Vaibhav
One Star

Re: Dynamic Database Connection using Context

I am using context variable, its having db connetion details and schema name. using context, we not able to pass schema value?
Four Stars

Re: Dynamic Database Connection using Context

Hi Madhu,
"SELECT *... your query goes here FROM "+context.db+"."+context.tablename
This is the way you can pass the values of context variable in query.
Thanks
Vaibhav