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。