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!

Trigger in mutating error while update

selvi mJul 7 2022

Hi
This trigger works fine while insert the data but update the records (start_date) that throws
SQL Error [4091] [42000]: ORA-04091: table grks_trade is mutating, trigger/function may not see itORA-06512: at "TRG_bktrade_BI", line 11
ORA-04088: error during execution of trigger 'TRG_bktrade_BI'

can you help me how to update below condtion throw raise_application_error
if((:NEW.START_DATE >= rec.START_DATE and :NEW.START_DATE <=rec.END_DATE) then
RAISE_APPLICATION_ERROR(-20001,'New record not a valid date');

code :
TRIGGER TRG_bktrade_BI
before INSERT OR UPDATE
ON grks_trade
FOR EACH ROW
begin
IF :NEW.COUNTRY<>'MAA' THEN
RAISE_APPLICATION_ERROR(-20001,'New record should be country is MAA');
END IF;
for rec in (SELECT COUNTRY,GROUP_NUM,START_DATE,END_DATE from grks_trade WHERE GROUP_NUM = :NEW.GROUP_NUM)
loop
if((:NEW.START_DATE >= rec.START_DATE and :NEW.START_DATE <=rec.END_DATE) then
RAISE_APPLICATION_ERROR(-20001,'New record not a valid date');
end if;
end loop;
end;

This post has been answered by Paulzip on Jul 8 2022
Jump to Answer

Comments

Post Details

Added on Jul 7 2022
11 comments
325 views