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: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Wed, 11 Jul 2001 19:01:54 +0200
Message-ID: <tkp1g1atgl2f69@beta-news.demon.nl>

"Jeff Boyer" <jdboyer@(remove)icomproductions.ca> wrote in message news:9ihuqm$srj$1_at_news3.cadvision.com...
> 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;
> > /
> >
> >
> >
> >
> >
> >

Why does everyone never include versions? If you are on 8i you could easily use the returning clause of the insert statement.
Also you could assign the sequence value to a packaged global variable, and you could retrieve it's currval to further process it, provided you do that right after the insert.
*NO* Need at all to put in yet another temporary table.

Regards,

Sybrand Bakker, Senior Oracle DBA

>
>
Received on Wed Jul 11 2001 - 12:01:54 CDT

Original text of this message

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