Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Selecting from sequence a specific number

Selecting from sequence a specific number

From: Ashraf Fouad <ash_mod2_at_hotmail.com>
Date: 25 Nov 2004 05:46:08 -0800
Message-ID: <471ffff0.0411250546.7ad01036@posting.google.com>


Dears,

    I'm having small requirment with a sequence.

Lets assume that I have sequence named "yyy_seq" If I executed "select yyy_seq.nextval from dual"
==> it will get me the value of next item in the sequence and advance
the pointer of the sequence for the value after it.

And
if I executed "select yyy_seq.nextval from table_zzz"
==> it will get me result set of range of sequence starting from next
value and ending with a value equals the start + # of rows in the table_zzz
i.e.:
Next value
Next value + 1
Next value + 2

...
...
...

Next value + # of rows in table_zzz

My need is:



I'm having a sequence, and I want to select range of values starting with the next value of this sequence and with length x, this specific value (x) is not known untill run time, and dynamic.

I have other solutions but there are problems in each one: 1- Loop x times over "select yyy_seq.nextval from dual" ==> From performance wise is not acceptable, I may have 1000 items so it will be very slow.

2- Get the first item in the sequence and then alter the sequence to start with this value + x, as I don't have this privilege on DB.

What I think should do the trick is to have the select statment return any dummy rows so generate the sequence as I wish, but it seems I can't figure it out!!!!!!!!!!

Thanks Received on Thu Nov 25 2004 - 07:46:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US