Re: How do I get an OUT parameter ref cursor from Oracle?
Date: Tue, 14 May 2002 16:34:03 -0700
Message-ID: <3CE19EEB.189A_at_ix.netcom.com>
jw < wrote:
>
> I have an Oracle stored proc that looks like:
>
> create or replace procedure GetMyStuff(myID in varchar2, myOut OUT
> types.cursorType)
> -- types.cursorType is defined as a ref cursor
>
> is begin
>
> open myOut for
> select * from mytable where id = myID;
>
> end;
>
> What is does the Java code look like to get the ref cursor? I can get a ref
> cursor returned by a function but now need to use an out paramter. I"ve this:
>
> Connection con = DriverManager.getConnection(url, user, passw);
> Statement st = con.createStatement();
> CallableStatement stm = con.prepareCall("{call GetMyStuff ?, ? )}"); //oracle
> stm.setString(1,"MY1234");
> stm.registerOutParameter(2,OracleTypes.CURSOR); //oracle
> boolean ans = stm.execute();
> ResultSet rs = (ResultSet) stm.getObject(1); //oracle
>
> but this isn't right. What am I doing wrong?
For one thing, you should be referencing parameter #2.
-- Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com) ============================================================== * The Ultimate DBMS is here! * FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)Received on Wed May 15 2002 - 01:34:03 CEST