Posts tagged: PL/SQL

Use SAVEPOINT in a DML loop

Imagine the following situation: You must process a number of records (in a loop or cursor) with the necessary updates / inserts / deletes. But you want that if it goes well that for that record the changes are saved and if it goes wrong for a record that the updates are then reversed. (In short: keep updates that are successful and roll back updates that fail – or possibly give that wrong record an “error status” or notification).

You can find my solution at https://github.com/HermanMol/oracle_scripts/blob/master/rollback_savepoint_in_loop_exceptions.sql

Herman Mol is powered by WordPress.  Staypressed theme by Themocracy