在Oracle JDBC中是否可以批量存储过程调用并检索OUT参数?

Kir*_*rby 9 java stored-procedures jdbc oracle11g batch-processing

我在Oracle 11g数据库中有一个存储过程,如f(a IN,b IN,c OUT).我想在批处理模式下从JDBC调用它,然后读取所有OUT变量.
这可能吗?到目前为止我有这个

  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 =  ?
Run Code Online (Sandbox Code Playgroud)

谢谢

Joh*_*tts 7

可悲的是没有.

对于CallableStatement对象,进行批量更新的能力与PreparedStatement对象相同.实际上,CallableStatement对象被限制为与PreparedStatement对象具有的功能相同.更确切地说,当使用批量更新工具时,CallableStatement对象只能调用带有输入参数或根本没有参数的存储过程.

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