Here is my code:
create or replace trigger tr_interdit
before delete on reservation
for each row
DECLARE
V_res_date RESERVATION.DATEFIN%type;
begin
SELECT DATEFIN into V_res_date
FROM reservation
where DATEFIN = :old.DATEFIN;
if V_res_date<add_months(V_res_date,-12)
then RAISE_APPLICATION_ERROR(-20001, 'Date fin na pas depasse un ans');
end if;
end tr_interdit;
/
But I'm getting this error when I delete a row from reservation after being deleted even though it should not be.
Here is the error:
DELETE FROM "DANIEL"."RESERVATION" WHERE ROWID = 'AAAFCvAABAAALHhAAA' AND ORA_ROWSCN = '3392006' and ( "NUMR" is null or "NUMR" is not null ) ORA-04091: table DANIEL.RESERVATION is mutating, trigger/function may not see it ORA-06512: at "DANIEL.TR_INTERDIT", line 4 ORA-04088: error during execution of trigger 'DANIEL.TR_INTERDIT'
:new.datefin- Ayubxon UbaydullayevIFcondition does not make sense.V_res_date<add_months(V_res_date,-12)will never be true. - a_horse_with_no_name