Cursor is closed

25,674

Since you have not provided the code, but according to my assumption, you are returning a cursor from the procedure by opening it, but at the same time you might be closing the cursor in the same procedure.

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;

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

Refer: Cursor is Closed

Share:
25,674
Sean Patrick Floyd
Author by

Sean Patrick Floyd

About me: Austrian / American Java developer / architect with 25+ years of experience, working in the Seattle Area for Domino Data Lab (views are my own). 50 y/o, married to a lovely German wife and father of three. Hold a 5th degree black belt in Taekwondo (Kukkiwon), love Monty Python and appreciate a good glass of Whisk(e)y. He / him. Java aficionado, dabbling in Scala / Kotlin / Groovy, off and on also JS, and Python or GoLang when I have to. Connect: Twitter, LinkedIn

Updated on November 22, 2022

Comments

  • Sean Patrick Floyd
    Sean Patrick Floyd over 1 year

    I am using struts framework. I am getting a "cursor is closed" error. I have checked my storedprocedure and it's working well in oracle but still I am getting the "cursor is closed" error.

        Caused by: 
    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)
    

    Can you help me understand what caused this?

    • Satya
      Satya almost 12 years
      please post your code which in your opinion is causing this so that we can have a look at
    • Sean Patrick Floyd
      Sean Patrick Floyd almost 12 years
      Struts is irrelevant, that's the front end. what's the back end like?
    • Admin
      Admin almost 12 years
      @SeanPatrickFloyd: Back end is oracle
    • Sean Patrick Floyd
      Sean Patrick Floyd almost 12 years
      @ShahnwazAlam yes, obviously. but accessed through plain JDBC, MyBatic, Spring-JDBC, Hibernate, JPA (etc.)?
    • Sean Patrick Floyd
      Sean Patrick Floyd almost 12 years
      @ShahnwazAlam ah, we're getting there. Now please post the java code were you call the stored procedure with hibernate