Re: getting sequence numbers?

From: Thomas J Kyte <tkyte_at_us.oracle.com>
Date: 1996/05/13
Message-ID: <31968db9.2258327_at_dcsun4>#1/1


nwa_at_protocom.com wrote:

>In article <3190BDAB.2640_at_mhasoftware.com>
>"brian (bubba) martin" <bmartin_at_mhasoftware.com> wrote:
>
>
>> i'm doing an multi-part insert into a database
>> and using a sequence for my primary. i need
>> to be able to pass that sequence number around
>> to point back to that record from othe update
>> procedures. i'm having trouble getting my var
>> on the seq.currval. seems oracle doesn't allow
 

>> We are what we post.
>
>declare
>val_var NUMBER;
>begin
>select seq.nextval into val_var from dual;
>insert into a values(val_var,....);
>insert into b values (val_var,...);
>..
>end;
>Using the currval in a production system is always a chancy thing
> since someone might do another insert between the time you
>generate a new sequence value and the time that you read the currval.
>Regards, mark

NO IT IS NOT. The currval you select is YOUR currval, never, never, never anyone elses. currval would be useless if this was not the case.

Nextval following by an infinite number of currvals will always return the same number, forever, regardless of the activity in the database.... The only thing that will change your currval is you doing a nextval call....

>
>

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government



opinions and statements are mine and do not necessarily reflect the opinions of Oracle Corporation. Received on Mon May 13 1996 - 00:00:00 CEST

Original text of this message