Is there a workaround for ORA-01795: maximum number of expressions in a list is 1000 error?

前端 未结 11 919
忘掉有多难
忘掉有多难 2020-11-27 16:14

Is there a workaround for

\'ORA-01795: maximum number of expressions in a list is 1000 error\'

I have a query and it is selecting fields based

11条回答
  •  囚心锁ツ
    2020-11-27 17:10

    I ran into this issue recently and figured out a cheeky way of doing it without stringing together additional IN clauses

    You could make use of Tuples

    SELECT field1, field2, field3
    FROM table1
    WHERE (1, name) IN ((1, value1), (1, value2), (1, value3),.....(1, value5000));
    

    Oracle does allow >1000 Tuples but not simple values. More on this here,

    https://community.oracle.com/message/3515498#3515498
    and
    https://community.oracle.com/thread/958612

    This is of course if you don't have the option of using a subquery inside IN to get the values you need from a temp table.

提交回复
热议问题