0

I want to insert a bunch of record in DB2 by a procedure and when an exception raises I want rollback all other insert before this insert and iterate loop for the next cursor record

 CREATE OR REPLACE PROCEDURE IMPORT_DATA_FROM_SIBA_ICMS2 (in IN_BRANCH_NO integer)
    LANGUAGE SQL
MAIN_BLOCK:
BEGIN
    DECLARE V_ID INTEGER DEFAULT NULL;
begin
insert into t1 --rollback this one when in the next on an exception occur
insert into t2
  --an exception occur
end;
hamidreza
  • 1
  • 2

1 Answers1

0

You may use the SAVEPOINT statement.
I can’t provide an exact code example since I don’t see any loops / cursors in your code snippet.

Mark Barinstein
  • 11,456
  • 2
  • 8
  • 16