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: Ed Prochak <prochak_at_my-deja.com>
Date: Wed, 01 Sep 1999 17:03:13 GMT
Message-ID: <7qjm88$ra6$1@nnrp1.deja.com>


In article <37CD4597.D651A515_at_fast.no>,   kev <kevin.porter_at_fast.no> 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
>
>

Within the trigger, just as you referenced NEXTVAL you can use CURRVAL for that sequence.

Within a package, you can use a package global variable and assign it the CURRVAL.

Across packages, you need to define access functions, which gets to be more Object oriented. (I usually don't create interfaces that require that level of complexity.)

Hope this helps.

--
Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3700 <<<NOTE new number

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Wed Sep 01 1999 - 12:03:13 CDT

Original text of this message

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