比如下面当向一张表插入一条记录时触发运行,但每次执行触发器都会对整张表进行操作,效率狂低啊
而我只想要对刚刚添加进去的该条记录进行操作
有没有办法,就是只对刚插进去的这一条记录进行操作!
create or replace trigger PDINSERT
after insert on t_kcd_subpandian declarebegin
update t_kcd_subpandian b
set normal_storage=( select a.cur_storage
from t_kc_info a
where a.deptid=(select c.deptid from t_kcd_pandian c where c.bill_id= b.bill_id) and a.place_id=b.place_id),
ms_unitid=( select d.main_unit
from t_bom_base d
where d.bom_id=b.bom_id);
update t_kcd_subpandian a
set profit=a.fact_storage-a.normal_storage;
end PDINSERT;
而我只想要对刚刚添加进去的该条记录进行操作
有没有办法,就是只对刚插进去的这一条记录进行操作!
create or replace trigger PDINSERT
after insert on t_kcd_subpandian declarebegin
update t_kcd_subpandian b
set normal_storage=( select a.cur_storage
from t_kc_info a
where a.deptid=(select c.deptid from t_kcd_pandian c where c.bill_id= b.bill_id) and a.place_id=b.place_id),
ms_unitid=( select d.main_unit
from t_bom_base d
where d.bom_id=b.bom_id);
update t_kcd_subpandian a
set profit=a.fact_storage-a.normal_storage;
end PDINSERT;
我现在把ID传进来用存储过程实现,不过我还是希望能搞明白这个问题!