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

Home -> Community -> Usenet -> c.d.o.tools -> Re: requesting Value of ID from Stored Procedure to JSP

Re: requesting Value of ID from Stored Procedure to JSP

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 27 Jun 2001 11:10:57 -0700
Message-ID: <9hd7jh02ope@drn.newsguy.com>

In article <b9fc24c.0106270932.247f7355_at_posting.google.com>, info_at_JennifersDesigns.com says...
>
>Hi,
>
>I am trying to use a Stored procedure called from a JSP to insert into
>a table (ultimately multiple tables).
>
>I am inserting sequence.nextval into the ID field. I cannot figure
>out how to retrieve the actual VALUE of the id field that was just
>inserted out of the SP and display it on the JSP page. The JSP page
>will have another form on it that will need to insert a related record
>where the ID needs to the be the same value... so on this second form
>I have to set a hidden field to the value of the result of getting the
>ID from the SP.
>
>Let's say I have a simple stored procedure such as:
>
>create or replace procedure test_proc
>(test_id_p in test.test_id%type,
>test_name_p in test.test_name%type)
>as
>begin
>insert into test(
>test_id_seqence.nextval,
>test_name)
>values
>(test_id_p,
>test_name_p);
>end test_proc;

create or replace procedure test_proc
(test_id_p in OUT test.test_id%type,
 test_name_p in test.test_name%type)
as
begin

   insert into test( test_id_seqence.nextval, test_name)    values (test_id_p, test_name_p)
   RETURNING test_id into test_id_p;

end test_proc;

and bind the first parameter as an OUT parameter in JDBC.

>
>How can I retrieve the value of test_id in this particular record that
>was inserted? I have tried placing test_id_p on the JSP but it always
>show null.
>
>Thanks!
>Jen

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Wed Jun 27 2001 - 13:10:57 CDT

Original text of this message

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