Getting ORA-04079: invalid trigger specification error for this trigger, can figure out why? Tables – TESTCOMM_FINDCOMM – 2 numbers, Price and Comm
create or replace trigger TESTCOMM_FINDCOMM
AFTER
insert or update on "TESTCOMM"
for each row
referencing new as new and old as old
begin
:NEW.Commission:= :NEW.Price*get_Comm(:NEW.Price);
end;
Function get_Comm
create or replace function get_Comm
(i_price in NUMBER)
return NUMBER
as
o_COMMISSION_percent PRICECOMMISSION.COMMISSION%type;
begin
select COMMISSION
into o_COMMISSION_percent
from (
select COMMISSION,
rank () over (order by Price desc) rnk
from PRICECOMMISSION
where PRICE <= i_price
) where rnk = 1;
return o_COMMISSION_percent;
end;
Your trigger is an AFTER insert/update trigger – you can not modify :NEW values after the insert/update.
More info on AFTER triggers can be found here. What you should be looking at is a BEFORE trigger.