views:

1591

answers:

1

The Oracle version of our database is 10g.

The stored procedure selects all the elements in a table and returns a REF CURSOR type as follows: create or replace

PROCEDURE S_S_TEST( 
  test_OUT OUT OAS_TYPES.REFCURSOR
) 
AS
BEGIN
  OPEN test_OUT FOR      
      SELECT *
      FROM table_p;
   CLOSE test_OUT;
END S_S_TEST;

When this stored procedure is executed in JAVA the following exception is obtained-

java.sql.SQLException: Cursor is closed. at oracle.jdbc.driver.T4CResultSetAccessor.getCursor(T4CResultSetAccessor.java:323) at oracle.jdbc.driver.ResultSetAccessor.getObject(ResultSetAccessor.java:85) at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1401) at com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement.getObject(WSJdbcCallableStatement.java:443)

I am trying to understand what the error is and how it could be fixed. Could someone please help me out?

Thanks!

+1  A: 

The client calling the stored procedure is responsible for closing the cursor. Please remove the code: CLOSE test_OUT;

The client closes it. In this case the client is the JDBC program that calls the stored procedure.

Brian