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: How can I use NEXTVAL in stored procedure??

Re: How can I use NEXTVAL in stored procedure??

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Tue, 08 Dec 1998 13:49:51 GMT
Message-ID: <366d2e07.2106899@inet16.us.oracle.com>


On Tue, 8 Dec 1998 10:38:19 -0000, "Dan Gibbons" <Daniel.Gibbons_at_Sebank.co.uk> wrote:

>Hi,
>
>I've just started to use Oracle and I'm trying to assign NEXTVAL to a
>variable in a strored procedure which I then want to use in an insert
>statement and return the new number via an output parameter. When I try and
>save the stored procedure I get "Can't use sequence in this context". This
>is the offending line:-
>
>pLOG_ID := GLMT_LOG_SEQ.NEXTVAL;
>
>Does anyone know how I can create a stored procedure that will assign
>NEXTVAL to a tables ID field and return the ID that it used?
>

You need to select the nextval of a sequence from the database.

Try:

select GLMT_LOG_SEQ.NEXTVAL
  into pLOG_ID
  from dual;

This will assign the nextval of the sequence to the variable pLOG_ID.

Hope this helps.

chris.

>Thanks in advance.
>
>Dan
>
>
>
>

--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Dec 08 1998 - 07:49:51 CST

Original text of this message

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