Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Retrieving the key of a newly inserted record
On 20 Dec 2002, claus_scherschel_at_operamail.com wrote:
> Hi everyone,
>
> I'm using an after insert trigger/sequence combination to
> create an incremental number for the table's primary key.
>
> I would like to write a stored procedure that executes an
> insert statement, writing the procedure's parameters into my
> table. That's not big deal. But I haven't a clue how to
> retrieve the primary key value of the new record. There's no
> other unique index which would help. Retrieving the row id
> would be sufficient, I think.
Use sequences.
On insert use seq_name.nextval then in same session you can ask for seq_name.currval.
-- Galen BoyerReceived on Fri Dec 20 2002 - 13:53:10 CST