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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Roman01
Contributor II
Contributor II

[RESOLVED] Use Context variable in component SQL

Hello Community,

I get an issue when I use the component tDBInput. I would like to use the context variable in SQL but it's not working.

I need to replace in the SQL the syntax in the clause FROM like :

"

SELECT

 

*

FROM

"NAV2K9R2-PROD".dbo."CK sa$Purch_ Inv_ Header"

I read on another post to use simple quote but I do not understand how it's work. I still have an error when I write like this :

SELECT

 

*

FROM

 

'

"

+

context.dbWorkflow_Database

+

"

.

"

+

context.dbNavision1_Schema

+

"

.

"

+

context.vPurchInvoice

"

'

How is it work in SQL to use context because I have the error 'Invalid object name' or '+' invalid syntax. ?

Thanks a lot,

Romain.

Labels (3)
2 Replies
Anonymous
Not applicable

Hello,

 

When you're running your job with log4j debug logs it will print the actual query submitted to the database. From that you could see how the parameters work. There's no variable substitution in talend. The queries are java Strings. So instead of:

"SELECT * FROM [TABLE]" you can use: "SELECT * FROM [" + context.table + "]"

And this will generate the right query.

Roman01
Contributor II
Contributor II
Author

Thank for you reply.

 

But I have still the error 'Incorrect syntax near '+'' (below attachment ) It seems the SQL doesn't work with double quote or the brackets are not working ?0695b00000IfoX9AAJ.jpg