JDBC oracle存储过程的更新计数为-1

时间:2018-02-19 21:44:21

标签: oracle stored-procedures jdbc

Oracle 11g,Java 8,ojdbc8

带有OUT REF_CURSOR的

存储过程,例如,

create or replace procedure foo(employeeId IN number, c OUT SYS_REFCURSOR) AS
BEGIN
    open c for select * from Employee where id = employeeId;
    update Employee set name='New Name" where id= employeeId;
END;

JDBC调用过程:

CallableStatement statement = connection.prepareCall("{call foo(?,?)}");
statement.setObject(1, 100);
statement.registerOutParameter(2, oracle.jdbc.OracleTupes.CURSOR);
statement.execute();

int count = statement.getUpdateCount(); // error: return -1
assertEquals(1, count);

更新计数应为1,但它为-1。

0 个答案:

没有答案