Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Context variable in SQL syntax

Hello.
Could anyone help me run the following SQL instruction please?
"SELECT *
FROM " + context.current_TABLE "

Context variable "current_TABLE" is defined in the parent job.
Which is the error in my SQL syntax ?
Thank you very much.
Labels (2)
10 Replies
Anonymous
Not applicable
Author

You just seem to have an extra double-quote - context.current_TABLE "
I'd recommend not using "*" and naming your fields. It will have some heartache later.
willm1
Creator
Creator

diarux - and make sure you're passing your context variables from the Parent to the child by checking the checkbox on the tRunJob component (transmit whole context). Other than that, should be "SELECT * FROM " + context.current_TABLE
Anonymous
Not applicable
Author

Hello.
Even if I use the following syntax, I still have an error :
"SELECT * FROM " + context.current_TABLE
I passed my context variable from the Parent to the child.
Context variable "current_TABLE" is defined as follows :
((String)globalMap.get("row1.nom_table"))
I don't understand why it doesn't work.
Anonymous
Not applicable
Author

You haven't actually said what the error is...
Anonymous
Not applicable
Author

Hi diarux,
Use the fallowing syntax for using context variables in sql.
"SELECT * FROM \""+context.current_TABLE+"\"".
Make sure that you have to enable transmit whole context check box in setting of tRunJob in parent job.

Regards,
Bhanu.
Anonymous
Not applicable
Author

Hi diarux,
Please upload your current job screenshots into forum so that we can see if there is wrong setting in your work flow.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hello.
Could you please take a look at the attached screenshot ?
Thank you for your help.
Anonymous
Not applicable
Author

hi all,
no screenshoot available 0683p000009MPcz.png (be sure about max size)
check the value passed by 'father job' to be sure it's not null
read some help from Talend :
https://help.talend.com/search/all?query=Passing+a+value+from+a+parent+Job+to+a+child+Job&content-la...
regards
laurent
Anonymous
Not applicable
Author

current_TABLE is defined in parent job as :
(String)globalMap.get("my-Table.nom_table")
num_utilisateur is defined in parent job as:
Integer.parseInt(jobName.substring(1,2))
Error message when running child job :
Exception in component tMSSqlInput_1
java.sql.SQLException: Syntaxe incorrecte vers 'FROM'

Still doesn't work.