Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Sequence ME!
sequence.currval
it gets the value AFTER the nextval
Ken Leach <KLeach_at_ids.net> wrote in article <352B9161.A96DBAFD_at_ids.net>...
> Sequence Problems
>
> This must be a common question but I have not seen it asked anywhere.
>
> I have a table with a primary key of type NUMBER(10), I have a trigger
setup
> to populate that field on insert based off the sequence. My problem is
when I
> insert a record into that table I need to know what number the row was
given,
> for use in other FK's.
> So if I insert one row, the on insert trigger will fire, populate the PK
field
> with the next sequence number and happily insert the row. How do get
that PK
> number once it is inserted.
>
> I need some sort of Insert/Select statement that inserts the line and
then
> returns a result set that only included the newly inserted line.
>
> I know I can get the next sequence number manually via; SELECT
SEQ_MRU.Nextval
> INTO lvi_MruNbr FROM dual;
> But wanted to know if there was a better way to handle this.
>
> Any suggestions are welcome.
>
> -Ken
>
>
Received on Thu Apr 09 1998 - 09:49:02 CDT