Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Retrieving the key of a newly inserted record

Re: Retrieving the key of a newly inserted record

From: Galen Boyer <galenboyer_at_hotpop.com>
Date: 20 Dec 2002 14:50:20 -0600
Message-ID: <uwum4xvrj.fsf@standardandpoors.com>


On 20 Dec 2002, claus_scherschel_at_operamail.com wrote:
> Galen Boyer <galenboyer_at_hotpop.com> wrote in
> news:u7ke4zczb.fsf_at_standardandpoors.com:
>

>> On insert use seq_name.nextval then in same session you can
>> ask for seq_name.currval.

>
> Wow, that was pretty fast. If I understand you correctly, I
> have to retrieve the seq-name.currval value within my stored
> procedure?

Yes. If you go into sqlplus and run the command

   select seq_name.currval from dual;

you will see an error. But, then run

   select seq_name.nextval from dual;

you will get a value. Now run

   select seq_name.currval from dual;

you will get the same value.

Open up another sqlplus session and do the same thing, then go back to the previous sqlplus session. Notice what numbers show up. That is how the numbers will behave for your proc.

> A thousand thanks, this sounds good to me.
>
> Regards, Claus.

-- 
Galen Boyer
Received on Fri Dec 20 2002 - 14:50:20 CST

Original text of this message

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