Oracle表级触发器

时间:2014-04-16 04:12:32

标签: sql oracle

我正在尝试查找项目A和Loc UK的数量更新时的日期和时间。 我可以在触发器中使用where子句吗?

CREATE TABLE tr_test (
item VARCHAR2 (10),
loc VARCHAR2 (10),
WHEN DATE,
qty );

insert into TR_TEST values ('A','UK',to_date('01/01/2013','MM/DD/YYYY',100);
insert into TR_TEST values ('B','US',to_date('01/01/2013','MM/DD/YYYY',200);

 CREATE OR REPLACE TRIGGER "TEST_TRIGGER"
   BEFORE UPDATE
   ON tr_test
   FOR EACH ROW
BEGIN
   IF UPDATING ('QTY')
   THEN

      INSERT INTO tr_test_1
                  (item, loc, WHEN, qty)
         SELECT :OLD.item, :OLD.loc, SYSDATE, :OLD.qty
           FROM DUAL;

      INSERT INTO tr_test_1
                  (item`enter code here`, loc, WHEN, oh)
         SELECT :OLD.item, :OLD.loc, SYSDATE, :NEW.qty
           FROM DUAL;
   END IF;
END;
/

0 个答案:

没有答案