在Oracle SQL Developer中更新另一个表后触发插入新行

时间:2016-06-01 17:27:57

标签: sql oracle triggers

我想在FREIGHTS表中创建新行后创建触发器,该触发器应在表INVOICES中创建新行。触发器应从表FREIGHTS获取值并将其放在表INVOICES中。

现在它看起来如下:

create or replace TRIGGER NewInvoice
AFTER INSERT ON FREIGHTS
FOR EACH ROW
BEGIN
 INSERT INTO INVOICES(id, netvalue, grossvalue, tax, receipient)
 SELECT '1', '1', weight, '1', '1'
 FROM FREIGHTS
END;

错误发生在最后的END声明中。

提前感谢您的支持;)

1 个答案:

答案 0 :(得分:1)

假设权重是FREIGHTS表中的一列:

create or replace TRIGGER NewInvoice
AFTER INSERT ON FREIGHTS
FOR EACH ROW
BEGIN
 INSERT INTO INVOICES(id, netvalue, grossvalue, tax, receipient)
  values ('1', '1', :new.weight, '1', '1');

END;

也许请阅读docs?