"Ref cursor is invalid"- Oracle, JDBC, Java, and me

"Ref cursor is invalid"- Oracle, JDBC, Java, and me

Post by grimscrib » Sat, 26 Aug 2000 04:00:00



Hi,

I'm having some problems with JDBC and Oracle; I'm trying to get
a cursor from an Oracle database, cast it as a ResultSet, and
then retrieve the values by row index.  Here's a code snippet:

                cstmt = dbConn.prepareCall("{call
clc_prior_pmt_select_prc (?,?)}");
                cstmt.setString(2, userID);
                cstmt.registerOutParameter(1,
OracleTypes.CURSOR);
                cstmt.execute();
                results = (ResultSet) cstmt.getObject(2);

Where "cstmt" is a CallableStatement and "results" is a
ResultSet.  I am able to setString and register the
outParameter, but right after it tries to execute the statement,
it chokes and says "ref cursor is invalid."

The stored procedure has the cursor as an OUT parameter, and it
is opened for Select within the stored procedure.

This is not exactly my strong point, I'll admit, and I'm
stumped; any ideas?

Thanks,
Michael

 
 
 

"Ref cursor is invalid"- Oracle, JDBC, Java, and me

Post by Konstantin Gordiyenk » Sat, 26 Aug 2000 04:00:00


Use ((oracle.jdbc.driver.OracleCallableStatement)cstmt).getCursor(2)
instead of cstmt.getObject(2).


> Hi,

> I'm having some problems with JDBC and Oracle; I'm trying to get
> a cursor from an Oracle database, cast it as a ResultSet, and
> then retrieve the values by row index.  Here's a code snippet:

>                 cstmt = dbConn.prepareCall("{call
> clc_prior_pmt_select_prc (?,?)}");
>                 cstmt.setString(2, userID);
>                 cstmt.registerOutParameter(1,
> OracleTypes.CURSOR);
>                 cstmt.execute();
>                 results = (ResultSet) cstmt.getObject(2);

> Where "cstmt" is a CallableStatement and "results" is a
> ResultSet.  I am able to setString and register the
> outParameter, but right after it tries to execute the statement,
> it chokes and says "ref cursor is invalid."

> The stored procedure has the cursor as an OUT parameter, and it
> is opened for Select within the stored procedure.

> This is not exactly my strong point, I'll admit, and I'm
> stumped; any ideas?

> Thanks,
> Michael

  konstantin.vcf
< 1K Download