Subject Re: [ib-support] IN clause, limitation to 1550 items
Author Adrian Roman
> I'm currently using IB 6 OpenSoucre version with my Delphi programs.
> I'm planning to migrate to Firebird in a near future. A limitation
> with IB 6 is that I cannot have more than 1500 items within the "IN"
> clause in a query.
>
> Example: SELECT * FROM PRODUCTS WHERE PRODUCTID IN ('PRODUCT1', '
> PRODUCT2, ...)
>
> Is this limitation is the same with Firebird ?

Wow! How did you reach that limit?

I would rather expect that limit is due of the sql string size.


I strongly suggest you change your design. For example put those PRODUCT1,
... in a table and use

SELECT * FROM PRODUCTS WHERE PRODUCTID IN (select PRODUCTID from
PRODUCT_TABLE)

You might even have a specific / client lists of products:

SELECT * FROM PRODUCTS WHERE PRODUCTID IN (select PRODUCTID from
PRODUCT_TABLE where CLIENTID=:ID)

Or even more, with a generator, a / query list.


Instead of building such long sql query, you could insert the PRODUCTIDs in
the PRODUCT_TABLE before running that query (using the ID if necessary), run
the query, and of course delete the unneeded records afterwards.



Adrian Roman