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 -> Re: Auto-incrementing primary key?

Re: Auto-incrementing primary key?

From: Andy Hardy <aph_at_ahardy.demon.co.uk>
Date: 1998/01/21
Message-ID: <hX8qHIAOkmx0EwEo@ahardy.demon.co.uk>#1/1

In article <34BE598E.7468_at_lilly.com>, Ed Bradt <ebradt_at_lilly.com> writes
>S Metro wrote:
>>
>> I also have the same dillemma. That solution sounds great, but what if
>> after inserting the row, you immediately need the value of the key. Since
>> the trigger used the NEXTVAL, can a user get the CURRVAL to find out what
>> was inserted?
>>

 [snip]
>
>Sure the user can get CURRVAL but there's no guarantee that someone else
>hasn't made another hit on the sequence in between. If you need to know
>what the key value is for further access to that same record then select
>and save myseq.nextval and use the saved value in the insert and
>subsequent queries for that row.
>Ed

The currval refers to the current session, so a nextval followed by a currval will always be correct.

Andy

-- 
Andy Hardy. PGP key available on request
===============================================================
Received on Wed Jan 21 1998 - 00:00:00 CST

Original text of this message

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