然后使用触发器中的Oracle中添加两个列,然后在第三列中插入一些值



我正在使用oracle 10 g我被告知使用触发器执行此任务,我已经提出了此

|`create trigger total
on inventory
after insert or update
for each row 
begin set 
:new.total=:new.stockin - :new.stockout +20;
end;`|

之前缺少错误我想要total = stockin -stockout 20

表清单

|stcokin |               |stockout |                | total|
 |-------|               |---------|                |------|
|2|                        |5|                         | 23|
  • 您应该使用:=
  • 分配
  • 您应该在更新或插入之前编辑新值。更新后(例如(更新其他表
  • 我认为您的触发名称也引起了问题。

so:

CREATE OR REPLACE TRIGGER trg_total BEFORE INSERT OR UPDATE ON inventory
FOR EACH ROW
BEGIN
    :NEW.total := :NEW.stockin - :NEW.stockout + 20;
END;

相关内容

最新更新