Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting multiple nextval's from a sequence

758141Aug 12 2010 — edited Aug 12 2010
Hi!

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
This post has been answered by Saubhik on Aug 12 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 9 2010
Added on Aug 12 2010
4 comments
11,018 views