Skip to content

Instantly share code, notes, and snippets.

@Brutt
Last active September 3, 2015 07:21
Show Gist options
  • Save Brutt/ca7e0c71141008485cc2 to your computer and use it in GitHub Desktop.
Save Brutt/ca7e0c71141008485cc2 to your computer and use it in GitHub Desktop.
Rollback_in_loop_2
/*using savepoint*/
declare
i integer;
cnt number := 0;
begin
insert into tbl_1
(id1)
values
(1);
for s in (SELECT t.* FROM all_objects t where rownum < 3) loop
cnt := cnt + 1;
execute immediate 'savepoint svp'||cnt;
begin
insert into tbl_2
(id2)
values
(1);
i := 7 / (2-2);
exception
when others then
execute immediate 'rollback to savepoint svp'||cnt;
dbms_output.put_line(SQLERRM || ' => ' || cnt);
end;
end loop;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment