One Star

concatenate context variable

Hi everyone,
I have a scenario where I can save SQL statement "SELECT * FROM" in contextA and "TABLENAME" in contextB.
The thing is I want to concatenate these two context variables in query parameter for database input component?
Is it possible?
Thanks in advance!
7 REPLIES
Community Manager

Re: concatenate context variable

Hi
What's your SQL statement looks like without context vairable?
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: concatenate context variable

Hi Shong,
It's just a simple SQL "SELECT * FROM EMPLOYEE" statement.
Regards,
Rozie
Community Manager

Re: concatenate context variable

Hi Shong,
It's just a simple SQL "SELECT * FROM EMPLOYEE" statement.
Regards,
Rozie

If the table name will be a variable, the query can be:
"select * from "+context.tableName
if the SQL has where condition, the query looks like:
"select * from "+context.tableName+" where id>10"
Hope this help you!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: concatenate context variable

Hi Rozie,
You can use tmap & in tmap join two columns using following function:-
row.column1+? ?+row.column2
Thanks
One Star

Re: concatenate context variable

Hi,
I have a SQL statement such that

select Q3.F0031 , Q4.F0171 , Q6.F1609,(Q3.F0031+Q3.F0032) as output
From STG_QSTN3 as Q3,STG_QSTN4 as Q4,STG_QSTN6 as Q6
where Q3.Estab_ID = Q4.Estab_ID
and Q3.Estab_ID = Q6.Estab_ID and Q4.Estab_ID = Q6.Estab_ID


Using the technique of context variable, I defined the SQL statement as "context.DOS_formula_Query".
Then in the excel file I separate the SQL statement into different sheet where the "select" statement I put in the sheet1 and "From...Where" statement I put in the sheet2.
Using the context variable, I called upon these statement using "context.DOS_formula_Query".
Is it possible to do above job? I found that the "From..Where" statement cannot be read. Is there any other alternative to do the job?
Below are the snapshot of the job.
Thanks in advance.
Regards,
naim
Community Manager

Re: concatenate context variable

Hi Naim
In the first and second images, there both has a same name called DOS_formula_Query. I think tContextLoad don't load the right value for the key DOS_formula_Query, because both sheets have a same key DOS_formula_Query. Can you check it?
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: concatenate context variable

I think you need different key names in the excel file and concatenate them in the database query.
keys DOS_formula_Select & DOS_formula_From
and in the query have context.DOS_formula_Select + " " + context.DOS_formula_From