Oracle触发器以当前行状态更新表

时间:2016-01-21 22:58:26

标签: sql oracle triggers timestamp

我在Oracle中有Timestamp字段的表格,一个关键字段和另外两列。我希望创建一个trigger,它将使用基于密钥,时间戳的当前状态行数据更新另一个表。新手触发,任何输入和/或推荐都将受到高度赞赏。

1 个答案:

答案 0 :(得分:1)

create or replace TRIGGER A
AFTER INSERT
ON A1
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW

DECLARE
BEGIN

UPDATE C SET COLC=:new.colc, D=:new.cold, TIMESTAMP=:new.timestamp WHERE KEY=:new.key;

EXCEPTION
 WHEN OTHERS THEN
   -- Consider logging the error and then re-raise
   RAISE;
END A;