For single output types my code is working fine but I couldn't get how to execute Oracle Procedure which has multiple output parameters and what will be the Output i.e ResultSet, Number etc.
abcProcedure(param1 OUT NUMBER,param2 OUT NUMBER,param3 OUT NUMBER,param4 OUT NUMBER,param5 IN OUT NUMBER, param6 IN NUMBER,param7 IN NUMBER)
Hibernate Code:
session.doWork(new Work(){
public void execute(Connection connection) throws SQLException {
CallableStatement callableStatement=connection.prepareCall("{call abcProcedure(?,?,?,?,?,?,?)}");
callableStatement.registerOutParameter(registerOutParameter,types.Numeric);
.......
callableStatement.execute();
}
}
Does anyone know how to do that?
Finally I have Solved it myself. Here is the solution
callableStatement.registerOutParameter(1,types.Numeric); //1 index of Out parameter
callableStatement.registerOutParameter(2,types.Numeric); //2 index of Out parameter
callableStatement.registerOutParameter(3,types.Numeric); //3 index of Out parameter
callableStatement.registerOutParameter(2,types.Numeric); //4 index of Out parameter
callableStatement.registerOutParameter(5,types.Numeric); //5 index of Out parameter
callableStatement.setLong(5, (Long)value); // 5 is also input parameter
callableStatement.setLong(6, (Long)value); // 6 input parameter
callableStatement.setLong(7, (Long)value); // 7 input parameter
callableStatement.execute();
callableStatement.getLong(1);// out put for param1
callableStatement.getLong(2);// out put for param2
callableStatement.getLong(3);// out put for param3
callableStatement.getLong(4);// out put for param4
callableStatement.getLong(5);// out put for param5
In case of multiple resultsets
callableStatement.getResultSet(); // will get the first ResultSet
callableStatement.getMoreResults();// will point to the next ResultSet
callableStatement.getResultSet();// will get the second ResultSet
..... So on
Thats it. :-)