简体   繁体   English

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

[英]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). 我在Oracle 11g数据库中有一个存储过程,如f(a IN,b IN,c OUT)。 I want to call it from JDBC in batch mode and then read all the OUT variables. 我想在批处理模式下从JDBC调用它,然后读取所有OUT变量。
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 谢谢

Sadly, no. 可悲的是没有。

The ability to make batch updates is the same for CallableStatement objects as it is for PreparedStatement objects. 对于CallableStatement对象,进行批量更新的能力与PreparedStatement对象相同。 In fact, a CallableStatement object is restricted to the same functionality that a PreparedStatement object has. 实际上,CallableStatement对象被限制为与PreparedStatement对象具有的功能相同。 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. 更确切地说,当使用批量更新工具时,CallableStatement对象只能调用带有输入参数或根本没有参数的存储过程。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM