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: Autoincremented id - how do I read it after insert?

Re: Autoincremented id - how do I read it after insert?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 01 Sep 1999 15:34:46 GMT
Message-ID: <37d4476b.104398817@newshost.us.oracle.com>


A copy of this was sent to kev <kevin.porter_at_fast.no> (if that email address didn't require changing) On Wed, 01 Sep 1999 16:26:15 +0100, you wrote:

>Hi,
>
>I have autoincremented id fields on several tables (using triggers and
>sequences).
>For some of them, I need to know the id value of the record I have just
>inserted, so that I can then insert a reference to that record in a
>'link' table (resolved many-many links). What's the best way of doing
>this?
>
>TIA,
>
>kev

select SEQUENCE_NAME.currval from dual

will give you the last sequence fetched by NEXTVAL in *your session*.

yes it works with many people using the sequence, currval always returns YOUR last nextval, not anyone elses.

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Sep 01 1999 - 10:34:46 CDT

Original text of this message

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