This discussion is archived
2 Replies Latest reply: Oct 18, 2013 8:07 AM by rp0428 RSS

Cannot perform fetch on a PLSQL statement: next

ram7 Newbie
Currently Being Moderated

Storedprocedure:

create or replace PROCEDURE ADDITION

(

  A IN NUMBER 

, B IN NUMBER 

, C OUT NUMBER 

) AS

BEGIN

  C := A+B;

  dbms_output.put_line(c);

END ADDITION;

 

JDBC program:

stmt = conn.prepareCall("BEGIN addition(?, ?,?); END;");

      stmt.setInt(1, 10);

      stmt.setInt(2, 85);

      stmt.registerOutParameter(3, java.sql.Types.INTEGER);

      ResultSet rs = stmt.executeQuery();

      while(rs.next()){

      int c =rs.getInt("c");

    System.out.println(c);

      }

 

 

 

      stmt.close();

      conn.close();

   }

Error:

java.sql.SQLException: Cannot perform fetch on a PLSQL statement: next

  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)

  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)

  at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:192)

  at stored_procedure.main(stored_procedure.java:32)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points