Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Calling a Stored procedure from Java which returns cursor value
try reading the JDBC docs at http://download-uk.oracle.com/otndoc/oracle9i/901_doc/java.901/a90211/toc.htm
pay attention to the "Oracle REF CURSOR Type Category" section of chapter 5 and the "REF CURSORs--RefCursorExample.java" of chapter 20 (http://download-uk.oracle.com/otndoc/oracle9i/901_doc/java.901/a90211/samapp.htm#1016411)
hth,
Marin
> 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.
>
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Marin Dimitrov INET: marin.dimitrov_at_sirma.bg 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 - 03:58:23 CST