Starting from the answer of this question (Use Bulk Collect result in a select query without cursor), I am wondering if it is possible to use the LIMIT option in SELECT ... BULK COLLECT INTO ...
I know the possibility to use an explicit cursor but I would like to know if it is possible using a direct select statement.
Thank you,
From the documentation:
So from the example in the previous question you linked to, you could do:
or if you're on 12c:
possibly with an order-by (in a subquery in the first version) for it to be deterministic.
The advantage of the explicit
fetch
version with thelimit
clause is that you can do that in a loop and keep fetching the next 1000 (or however many) rows until you've seen them all. With theselect
version you only get one shot; unless you put that in a loop and handle paging, and even then as eachselect
is independent the data could change between queries (unless you also change the isolation level).