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: 
SkyTate
Contributor
Contributor

Data loader SQL with Where in using an arrary

I would like to replace the following code in Qlik Sense Data Loader

SQL
SELECT
I_PLT,
DEPTCODE,
LINECODE,
X_LINE_DESC

from m.maslin
WHERE I_PLT in ('02462','02470','04012','04025')
with UR;

With something like this:

set vPlantsToLoad = 02462,02470,04012,04025;

SQL
SELECT
I_PLT,
DEPTCODE,
LINECODE,
X_LINE_DESC

from m.maslin
WHERE I_PLT in '$(vPlantsToLoad)'
with UR;

Labels (1)
3 Replies
rachel_delany
Creator II
Creator II

Your variable needs to match how you've formatted your filter in the first part.

E.g. set vPlantsToLoad = ('02462','02470','04012','04025');

SkyTate
Contributor
Contributor
Author

I had already tried that. When I do it like that I get the following error. 

 

The following error occurred:
Connector reply error: SQL##f - SqlState: 42601, ErrorCode: 4294967192, ErrorMsg: [IBM][CLI Driver][DB2] SQL0104N An unexpected token "'(''02462'',''02470'',''04012'',''04025'')'" was found following "". Expected tokens may include: "(". SQLSTATE=42601
The error occurred here:
SQL
SELECT
I_PLT,
DEPTCODE,
LINECODE,
X_LINE_DESC
 
from m.maslin
 
WHERE I_PLT in '(''02462'',''02470'',''04012'',''04025'')'
rachel_delany
Creator II
Creator II

Can you include the part of your script where you set the variable?