Getting multiple nextval's from a sequence
758141Aug 12 2010 — edited Aug 12 2010Hi!
We have a global id sequence (on RAC) that looks like this:
CREATE SEQUENCE SEQ_GLOBALID MINVALUE 0 MAXVALUE 218340105584895 INCREMENT BY 1 START WITH 0 CACHE 5000 NOORDER NOCYCLE
I used to fetch single numbers from the sequence by querying
SELECT SEQ_GLOBALID.nextval FROM dual
and repeating this for every sequence value I needed. But now I need to draw 5000 values from the sequence in a bulk, i.e. I want to fetch 5000 numbers with just one query, rather than doing the round trip five thousand times -- for performance reasons. Is there any way of fetching n sequence values in one statement?
Regards,
Christian
P.S.: To clarify: we are using the sequence numbers in our application, not in INSERTS, that's why I'm fetching them.
Edited by: Christian Menke on 12.08.2010 00:38