Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Row level trigger & raise application error

Dev_SQLNov 5 2019 — edited Nov 8 2019

Hi All,

I've one simple question on Triggers, could be very silly , I searched my best, couldn't get the information I wanted, so please help, thank you.

I'm using a Row-Level trigger, my Update statement updates two rows, here, when I raise an error for just one row, the entire statement gets aborted, not just the Erroneous row alone. Does it happen as the entire statement is considered as a single Transaction? Could you please give some details on this?

create table tmp_emp_100

(emp_id number(4),

emp_name varchar2(100));

insert into tmp_emp_100

values(101, 'Emp101');

insert into tmp_emp_100

values(102, 'Emp102');

commit;

select * from tmp_emp_100;

create or replace trigger trg_emp_100

before update on tmp_emp_100

for each row

begin

  if :new.emp_id=102 then

    raise_application_error(-20001, 'Error on 102');

  end if;

end;

update tmp_emp_100

set emp_name=emp_id || ' changed';

This post has been answered by Cookiemonster76 on Nov 5 2019
Jump to Answer
Comments
Post Details
Added on Nov 5 2019
7 comments
2,534 views