Split a collection into subcollections of a specific size

18 May

Recently I had to work with a Oracle instance and had to use a query that uses a subquery like (the IN … statement) this

SELECT * FROM table_a WHERE id IN (...)

The method I had to implement/fix takes an arbitrary number of ids as arguments.. if you get
more than 1000 ids, Oracle will spill a message like this into your fa.. aehm.. onto your console:

"ORA-01795 maximum number of expressions in a list is 1000"

To “fix” this problem, I wrote a small utility class that creates sub-collections of a specific maximum size out of a given collection.

Here it is:

Comment Form