我有桌子Inventory
"INVENTORY_CODE" VARCHAR2(20) NOT NULL ENABLE
"ITEM_CODE" VARCHAR2(20) NOT NULL ENABLE
"WAREHOUSE_CODE" VARCHAR2(20)
"CON_TON" NUMBER(38,5)
"IN_Q_TON" NUMBER(38,5)
"OR_Q_TON" NUMBER(38,5)
"RES_TON" NUMBER(38,5)
"RET_TON" NUMBER(38,5)
"ST_INV" NUMBER(38,5)
和另一张桌子Inventory_warehouse
"CODE" VARCHAR2(20) NOT NULL ENABLE
"ITEM_CODE" VARCHAR2(20) NOT NULL ENABLE
"QUANTITY_AV_TON" NUMBER(38,5)
"QUANTITY_AV_REAM" NUMBER(38,5)
"QUANTITY_AV_SHEET" NUMBER(38,5)
我想触发计算QUANTITY_AV_TON
作为
QUANTITY_AV_TON = IN_Q_TON + RES_TON + RET_TON + ST_INV - CON_TON - OR_Q_TON
我创建了这个触发器,但它不起作用
create or replace trigger QUANTITY_TON
AFTER insert or update or delete on INVENTORY
for each row
begin
UPDATE INVENTORY_WAREHOUSE
SET QUANTITY_AV_TON =
select (IN_Q_TON + RES_TON + RET_TON + ST_INV - CON_TON -OR_Q_TON)
from inventory
where INVENTORY.item_code = INVENTORY_WAREHOUSE.item_code;
end;
IN_Q_TON
, RES_TON
, RET_TON
, ST_INV
, CON_TON
,的值是OR_Q_TON
使用触发器从其他表中计算出来的