我正在编写oracle sql trigger
CREATE OR REPLACE TRIGGER scheme1.INSERTING_TRIGGER AFTER INSERT ON scheme1.Bill
FOR EACH ROW
BEGIN
INSERT INTO scheme2.DM_LOGGER(ID, TECHNOLOGY, WORKFLOW, NAME_EVENT, TIME_EVENT)
VALUES(scheme1.Bill.id,'Repository','UP','Accepted', SYSDATE);
END;
它会引发以下错误:
如果我的猜测是正确的,则问题出在DM_LOGGER的ID列中。 但我不确定它有什么不对。我只想在记录器中自动插入新的Bill记录中的id。
答案 0 :(得分:4)
您需要使用NEW
记录:
CREATE OR REPLACE TRIGGER scheme1.INSERTING_TRIGGER AFTER INSERT ON scheme1.Bill
FOR EACH ROW
BEGIN
INSERT INTO scheme2.DM_LOGGER(ID, TECHNOLOGY, WORKFLOW, NAME_EVENT, TIME_EVENT)
VALUES(:NEW.id,'Repository','UP','Accepted', SYSDATE);
END;
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/triggers.htm#LNPLS99955