Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Calling a Stored procedure from Java which returns cursor value
Hi all
I was running following code in from this list only and I want to call it from java code. Code is
CREATE OR REPLACE PACKAGE Apack AS
TYPE RefCurTyp IS REF CURSOR;
END APACK;
/
CREATE OR REPLACE PROCEDURE demo_ref (
refcurvar IN OUT Apack.RefCurTyp,
choice NUMBER) IS
BEGIN
IF choice = 1 THEN
OPEN refcurvar FOR SELECT * FROM emp;
ELSIF choice = 2 THEN
OPEN refcurvar FOR SELECT * FROM dept;
ELSIF choice = 3 THEN
OPEN refcurvar FOR SELECT * FROM salgrade;
END IF;
END demo_ref;
/
The procedure above works very fine if I just execute it on SQL
after declaring a refcursor variable x
SQL> exec demo_ref(:x,2). BUT How to run this procedure from Java
Code. I can use 'Call' statement in Java and ? ? as variables ,
however what will replace :x on Oracle in Java file. I am still
having problems in calling it from java. (I can convert it to
function and then call it successfully from java , but I think
there must be some way out in Java for calling SP)
NG
P.S. I can call SP from java which is accepting parameter but not returnin value.
Amol
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Nandu Garg INET: focussed_at_rediffmail.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Fri Mar 22 2002 - 01:13:23 CST