Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
stucas
Contributor
Contributor

Implicit load context - setting up retrieval from DB

Hi
I'm new to Talend and trying to get up to speed very quickly, with a view to configuration of my jobs I've been reading the blog series:
https://www.talend.com/blog/2019/02/28/best-practices-for-using-context-variables-with-talend-part-3...

 

I've attempted to replicate this but am getting Java compilation errors, and finally need to seek some help to understand why the embedded code is failing, or indeed my assumptions are correct:


I'm assuming that in the article, the resolution of the column names which are in the format "schema.table.columnName" (e.g. schema and table) were not changed and in fact, cannot be changed - (though the article implies you can). The side effect of doing this is that the generated code is unable to write the embedded value correctly in the generated code and you get in essence a java string for the select statement with your values (which should be code) embedded in it:

 

The following is generated if I set the schema and table to "public" and "context_Variables" respectively:
String dbquery_Implicit_Context_Database = "SELECT \n \"public\".\"context_variables\".\"key\", \n \"public\".\"context_variables\".\"value\"\nFROM \"public\".\"con"
+ "text_variables\"";

When I 'parameterise' them I get the following generated (note that the table name hasn't even been attempted to be injected):

String dbquery_Implicit_Context_Database = "SELECT \n \"UcasConfiguration.getImplicitContextParameterValue("talend.configuration.configurationDB.schema")\".\"_MyTable_\".\"key\", \n \"UcasConfiguration.getImplicitContextParameterValue("talend.configuration.configurationDB.schema")\".\"_MyTable_\".\"value\"\nFROM \"UcasConfiguration.getImplicitContextParameterValue("talend.configuration.configurationDB.schema")\".\"_MyTable_\"";

My conclusion is that you are only able to parameterise connection strings, not the actual database structure.

Is anyone able to concur - or show me what I'm thinking is just plain, bogus!

Many thanks!

 

 

Labels (3)
1 Reply
vapukov
Master II
Master II

Hi,

 

from examples it not seen all possible errors, but at least one is seen clear:

when you want to use context variable, you do not need to enclose them into brackets "", but must add prefix context.

context.context_variable 
for table name, instead of
"context_variable"