店舗手続き
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 プログラム
cstmt = conn.prepareCall("BEGIN addition(?, ?,?); END;");
cstmt.setInt(1, 10);
cstmt.setInt(2, 85);
cstmt.registerOutParameter(3, java.sql.Types.INTEGER);
ResultSet rs = cstmt.executeQuery();
while(rs.next()){
int c =rs.getInt("c");
System.out.println(c);
}
上記のプログラムプログラムの実行中にエラーが発生します。
エラー:
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)