Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in Oracle JDBC is it possible to batch stored procedure calls and retrieve OUT parameters?

I have a stored procedure in an Oracle 11g database like f(a IN, b IN, c OUT). I want to call it from JDBC in batch mode and then read all the OUT variables.
Is this possible? I have this so far

  CallableStatement statement = connection.prepareCall("f(?, ?, ?)");
  for(Item i : items) {
     int i = 0;
     statement.setString(++i, item.getA());
     statement.setString(++i, item.getB());
     statement.registerOutParameter(++i, Types.NUMERIC);
     statement.addBatch();
  }
  statement.executeBatch();
  int[] answers =  ?

Thanks

like image 792
Kirby Avatar asked Jun 02 '12 00:06

Kirby


1 Answers

Sadly, no.

The ability to make batch updates is the same for CallableStatement objects as it is for PreparedStatement objects. In fact, a CallableStatement object is restricted to the same functionality that a PreparedStatement object has. More precisely, when using the batch update facility, a CallableStatement object can call only stored procedures that take input parameters or no parameters at all.

Reference: http://docs.oracle.com/javase/1.4.2/docs/guide/jdbc/getstart/callablestatement.html#1000220

like image 142
John Watts Avatar answered Sep 30 '22 14:09

John Watts