我正在使用postgresql。这些是触发器中涉及的表:
定价(标题,出版商,期间,报价,价格)
问题:
Write a trigger that adds a new row in the pricing table.
If a new row is inserted with offer='regular', insert a new row, exactly the same BUT:
offer='renew' and a price discount of 10%.
这是我的触发器,它不起作用:
create or replace function offer_f() returns trigger as $$
begin
if(TG_OP='insert') then
if new.offer='regular' then
insert into pricing (title,pusblisher,offer,period, price)
values (new.title,new.publisher,"renew",new.period,new.price*0.9);
end if;
end if;
return new;
end;
$$
language plpgsql;
这是触发器本身:
create trigger reduced_offer
after insert or update on pricing
for each row
execute procedure offer_f()
我真的不知道这里有什么问题,我已经尝试过更换""" "之前"在触发器中。
谢谢,
艾伦