在Oracle JDBC中是否可以批量存储过程调用并检索OUT参数? [英] in Oracle JDBC is it possible to batch stored procedure calls and retrieve OUT parameters?
问题描述
我在Oracle 11g数据库中有一个存储过程,如f(a IN,b IN,c OUT)。
我想在批处理模式下从JDBC调用它然后读取所有OUT变量。
这可能吗?
到目前为止我有这个
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 = ?
谢谢
推荐答案
可悲的是,没有。
批量更新的能力与CallableStatement
对象相同,因为它是对于PreparedStatement对象。实际上,
CallableStatement对象被限制为与PreparedStatement对象具有的
相同的功能。更确切地说,当使用批量
更新工具时,CallableStatement对象只能调用存储的
过程,这些过程接受输入参数或根本没有参数。
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.
参考: http://docs.oracle.com/javase/1.4.2/docs/guide/jdbc/getstart/callablestatement.html#1000220
这篇关于在Oracle JDBC中是否可以批量存储过程调用并检索OUT参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!