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 to use in Stored procedure

Re: How to use in Stored procedure

From: Gabriel Gonzalez <no-spam_at_no-spam.com>
Date: Wed, 12 Feb 2003 14:45:15 -0800
Message-ID: <3e4ab329$1_2@binarykiller.newsgroups.com>

> my question is how to use the sequence creation statement within the
> procedure and return the id back from stored procedure to calling
> programs.

Dude, if you do what you describe, then your procedure will always return the value of 1 because you'd be creating the sequence over and over, with an initial value of 1. You need to create the sequence only once, and then your procedure returns the next value of the sequence.

Here's what the procedure would look like (untested code):

create or replace function getid as is id number is v_val number;
begin

    select do_id.nextval into v_val from dual;     return(v_val);
end;

Maybe this would also work (try it out):

create or replace function getid as is id number is begin

    return(select do_id.nextval from dual); end;

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------

   http://www.newsfeed.com The #1 Newsgroup Service in the World! -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =----- Received on Wed Feb 12 2003 - 16:45:15 CST

Original text of this message

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