Oracle PL/SQL - PL SQL SQL Statement Partial Rollback

Introduction

In a partial rollback, Oracle allows you to insert a savepoint in the transaction.

In this case, you may roll back the most recent changes in the transaction.


declare
     v_errors_yn VARCHAR2(1) := 'N';
begin
     update emp set sal = sal * 1.1                                          
     where deptNo = 10;
     savepoint SaveDept10Update;
     update emp set sal = sal * .9
     where deptNo = 20;                                              

     select decode (count(*),0,'N','Y')

     into v_errors_yn
     from t_logError;
     if v_errors_yn = 'Y' then                                           
        Rollback to SaveDept10Update;                                    
     end if;
end;

Names of savepoints follow the same naming rules and restrictions as variable names.

Related Topic