plsql - Oracle: Rollback only crash iteration of loop -


i need accomplish rollback on iteration if 1 or more iterations crash , commit others iteration if success. if crash, rollback whole transaction. think can done savepoints, i'm not familiar them. basic example try achieve.

    declare        ...     begin       in 1 .. 10       loop         begin           -- dml , stored procs dml           insert .. .;           insert b .. .;           insert .. .;           delete .. .;           update c .. .;           m_package.some_proc_with_dml;         exception           when others             merror   := merror + || ', ' || + sqlerrm;             miserror := true;         end;       end loop;        commit;        if miserror         raise_application_error(-20000, merror);       end if;      end; 

thanks in advance.

you can set savepoint, , rollback savepoint e.g.:

    declare        ...     begin       in 1 .. 10       loop         begin          savepoint my_savepoint_name;  -- dml , stored procs dml           insert .. .;           insert b .. .;           insert .. .;           delete .. .;           update c .. .; m_package.some_proc_with_dml;         exception           when others             merror   := merror + || ', ' || + sqlerrm;             miserror := true;              rollback my_savepoint_name;          end;       end loop; 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -