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

拥有回忆 提交于 2019-12-10 02:47:11

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/10858816/in-oracle-jdbc-is-it-possible-to-batch-stored-procedure-calls-and-retrieve-out-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!