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: 
DirkCtz
Contributor II
Contributor II

List within a variable to use in SQL select

Hi

I have a list of customer numbers I write to a list and then store it in a variable, ie

vList = 12345, 875895, 98371.... (less than 1000 customer numbers in the list).

I then try to use the variable in a SQL script in the loader, something like:

SQL Select * from Table where Customer_Num in ($(vList));

But I get the following error: Syntax error: expected something between '(' and ')'.

If I type the Customer numbers into the SQL in the following format manually, i.e. '12345, 875895, 98371' - - it works. But when I try doing it in the variable, it doesnt work and gives above error.

I also tried  char(39) & vList & char(39)... no luck

Any advice?

2 Replies
maxgro
MVP
MVP

SET vList = 12345, 875895, 98371 ;

// try this

SQL Select * from Table where Customer_Num in ('$(vList)');

// or this
SQL Select * from Table where Customer_Num in ($(vList));

DirkCtz
Contributor II
Contributor II
Author

Thank you..

Unfortunately neither of these options work 😞

The within the variable I store a concatenated list. If I type in the
customer numbers in the variable it does work, but if i assign the
concatenated list to the variable it doesn’t work.