Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Workaround for SQL 1000 maximum numbers in a list

cutehappybear
7 - Meteor

Hello everyone,

 

I have a variable that goes like this ('123', '234', '845', '39429',...) etc.

I use that variable in a Dynamic Input, to do something like:

SELECT (blablabla) FROM (blablabla) WHERE (blablabla) IN ('123', '234', '845', '39429',...).

 

The problem is that my list contains more than 1000 numbers, and therefore I get an error like:

Dynamic Input: Error: OraOLEDB: ORA-01795: maximum number of expressions in a list is 1000; OraOLEDB: ORA-01795: maximum number of expressions in a list is 1000 in Query...

 

Is there anyway in which I can split my list (which has more than 3000 records, but in the future it could even have 5000 or more), in several lists of less than 1000?

And then do several queries like

 

select field1, field2, field3 from table1 
where  name in ('value1', 'value2', ..., 'value999') 
    or name in ('value1000', ..., 'value1999') 
    or ...;

Thank you very much!

2 REPLIES 2
fmvizcaino
17 - Castor
17 - Castor

Hi @cutehappybear ,

 

Yes, and weirdly enough, I needed to do the same thing due to an issue I don't really recall. 😁

You could use a tile tool to separate our dataset in groups of 1000 values and it would look something like this.

fmvizcaino_0-1665523507256.png

 

Best,

Fernando Vizcaino

 

Felipe_Ribeir0
16 - Nebula

Hi @cutehappybear 

 

I had a similar problem here, and i solved it like this (workflow attached):

 

Felipe_Ribeir0_0-1665578554825.png

 

 

1)Have a table with the values to populate the IN clause

 

Felipe_Ribeir0_1-1665578577262.png

 

2)Create groups of 999 (or the amount that you want) rows each

 

Felipe_Ribeir0_2-1665578649749.png

 

3)Create the IN clause for each group

 

Felipe_Ribeir0_3-1665578682126.png

4)Properly configure the Dynamic Input Tool to run the query with each group of ID`s. This is done by fixing a random value at the query (here i used 999), and replacing this value with the column with the IN values previously created.

 

Felipe_Ribeir0_4-1665578758884.png

Felipe_Ribeir0_5-1665578785608.png

 

As you can see here, the queries were executed dynamically:

 

Felipe_Ribeir0_0-1665579929979.png

 

If the provided answer helped you to solve the problem/was correct, please accept it as a solution :)

 

Thanks.

 

Labels