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

Home -> Community -> Usenet -> c.d.o.server -> Re: Here is a good one ;-)

Re: Here is a good one ;-)

From: Frank Hubeny <fhubeny_at_ntsource.com>
Date: Sat, 21 Jul 2001 21:35:03 GMT
Message-ID: <3B4E8899.31C7D3A6@ntsource.com>

The following might work and serve as an example.

create or replace procedure feedback_id_proc is

   temp varchar2(30);
begin

   insert into feedback (feedback_id)
   values ('FB' || to_char(feedback_id_seq.nextval))    returning feedback_id into temp;
   dbms_output.put_line(temp);
end;

After it is compiled, you can run it as follows:

SQL> set serveroutput on
SQL> exec feedback_id_proc
FB1

Frank Hubeny

Jeff Boyer wrote:

> Ok, I have figured out that I need to use a stored procedure so that I can
> return the value of the new feedback Id. However, I am confused as to how
> to return this value. This is the procedure I am using:
>
> CREATE OR REPLACE PROCEDURE Feedback_Id_Proc IS
> Temp varchar2(30);
> BEGIN
> SELECT Feedback_ID_SEQ.NEXTVAL
> INTO Temp FROM DUAL;
> Temp := 'FB-'||Temp;
> Insert into Feedback (Feedback_Id) Values (Temp);
> return(?????);
>
> End;
> /
>
> If someone could help me out with what I need to return it would be greatly
> appreciated.
>
> Thanks again,
> Jeff
>
> "Jeff Boyer" <jdboyer@(remove)icomproductions.ca> wrote in message
> news:9ihupj$sri$1_at_news3.cadvision.com...
> > Ok people, I am using Oracle 8i and for a front end I have a feedback
> > process online using VBScript. In this feedback process I have a form
 that
> > inserts all the information for the feedback into my feedback table.
> > However ,before any of it happens I have a trigger that inserts a feedback
> > id before anything is inserted. The insertion happens when the submit
> > button is pressed. What happens next is where I am stuck. When you hit
 the
> > submit button, you are taken to a web page that gathers a little more
> > information regarding contact information and so forth. On this page I
 need
> > to be able to update that record that was just created in the feedback
> > table. In order to do this I need to know that feedback Id that my
 trigger
> > just created for me. Is there any way at all to get that id back out of
 the
> > database? I have been banging my head against a wall for a week now and
> > can't seem to get it. Just for your information the trigger I use to
 insert
> > the feedback id is below.
> >
> > CREATE OR REPLACE TRIGGER Feedback_Id_trg
> > BEFORE INSERT on Feedback
> > FOR EACH ROW
> > DECLARE
> > Temp varchar2(30);
> > BEGIN
> > SELECT Feedback_ID_SEQ.NEXTVAL
> > INTO Temp FROM DUAL;
> > Temp := 'FB-'||Temp;
> > :New.Feedback_id := Temp;
> >
> > End;
> > /
> >
> >
> >
> >
> >
> >
Received on Sat Jul 21 2001 - 16:35:03 CDT

Original text of this message

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