Skip to content

Instantly share code, notes, and snippets.

@torstenwerner
Last active July 19, 2020 10:05
Show Gist options
  • Save torstenwerner/d4a27754441c16ce96a85fd68695ed23 to your computer and use it in GitHub Desktop.
Save torstenwerner/d4a27754441c16ce96a85fd68695ed23 to your computer and use it in GitHub Desktop.
Oracle jdbc update with returning clause
declare
o0 dbms_sql.varchar2_table;
o1 dbms_sql.varchar2_table;
c0 sys_refcursor;
c1 sys_refcursor;
begin
update "C##TEST"."AUTHOR"
set "C##TEST"."AUTHOR"."FIRST_NAME" = ?
where "C##TEST"."AUTHOR"."LAST_NAME" = ?
returning "C##TEST"."AUTHOR"."FIRST_NAME", "C##TEST"."AUTHOR"."LAST_NAME" bulk collect into o0, o1;
? := sql%rowcount;
open c0 for select * from table (o0);
open c1 for select * from table (o1);
? := c0;
? := c1;
end;
@torstenwerner
Copy link
Author

torstenwerner commented Jul 19, 2020

How to call java.sql.CallableStatement#registerOutParameter(int, int):

  • output parameter 3 is INTEGER, sqltype = 4 see java.sql.Types#INTEGER
  • output parameters 4 and 5 are sql type = -10 see oracle.jdbc.OracleTypes#CURSOR

Explicit transactions: https://docs.oracle.com/javase/tutorial/jdbc/basics/transactions.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment