sql 中的更新触发器
update triggers in sql
我想在更新特定行时实现触发器。
商品中有一个名为 pno 的属性 table。
create table logFile
(
pno int primary key,
user_name varchar(100),
date_chan date,
old_Price int,
new_Price int
);
create or replace trigger update_price_property
AFTER UPDATE OF price ON offer
IF pno = 80 // this won't work, how can I add this condition?
BEGIN
insert into logFile values (:old.pno, user, sysdate, :old.price, :new.price);
END;
/
您可以将其表述为 insert
:
BEGIN
insert into logFile
select :old.pno, user, sysdate, :old.price, :new.price
from dual
where :old.pno = 80; -- or is this :new.pno?
END;
当然,你也可以使用if
条件。
我想在更新特定行时实现触发器。
商品中有一个名为 pno 的属性 table。
create table logFile
(
pno int primary key,
user_name varchar(100),
date_chan date,
old_Price int,
new_Price int
);
create or replace trigger update_price_property
AFTER UPDATE OF price ON offer
IF pno = 80 // this won't work, how can I add this condition?
BEGIN
insert into logFile values (:old.pno, user, sysdate, :old.price, :new.price);
END;
/
您可以将其表述为 insert
:
BEGIN
insert into logFile
select :old.pno, user, sysdate, :old.price, :new.price
from dual
where :old.pno = 80; -- or is this :new.pno?
END;
当然,你也可以使用if
条件。