SQL触发器 - 无法调用函数

时间:2012-07-04 17:50:59

标签: sql oracle function triggers

获取ORA-04079:此触发器的触发器规范错误无效,可以找出原因?表格 - TESTCOMM_FINDCOMM - 2个数字,价格和通讯

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;

功能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;​

1 个答案:

答案 0 :(得分:3)

您的触发器是一个AFTER插入/更新触发器 - 您无法修改:插入/更新后的新值。

有关AFTER触发器的更多信息,请here。您应该关注的是BEFORE触发器。