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: <cary_at_nams.net>
Date: Tue, 08 Dec 1998 15:50:36 GMT
Message-ID: <74jhsb$vvm$1@nnrp1.dejanews.com>


Hi,

    If I understand correctly, I believe what you want is something like:

CREATE OR REPLACE PROCEDURE PROCESS_ID(tmp_id IN OUT INTEGER) AS BEGIN
  SELECT GLMT_LOG_SEQ.NEXTVAL INTO tmp_id FROM DUAL;   INSERT INTO my_table (table_id) VALUES (tmp_id); END PROCESS_ID; Upon completion of this procedure, the actual parameter in the calling environment corresponding to the formal parameter 'tmp_id' will contain the value NEXTVAL from the sequence. Hope this helps.

Cary

In article <74ivo0$pg31_at_pound.sebank.se>,   "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?
>
> Thanks in advance.
>
> Dan
>
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Dec 08 1998 - 09:50:36 CST

Original text of this message

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