【问题标题】:update triggers in sqlsql中的更新触发器
【发布时间】:2021-03-04 09:55:01
【问题描述】:

我想在特定行更新时实现触发器。

offer 表中有一个名为 pno 的属性。

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;
/

【问题讨论】:

  • 这样做我得到了一个编译错误..

标签: sql oracle11g sqlplus


【解决方案1】:

您可以将其表述为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 条件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 2011-06-03
    • 2017-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多