--目的:在审核后更新的金蝶K3系统中的生产任务单同步显示关联数量(已审核入库数+未审核入库数)
--相关查询
select
fauxstockqty,  --入库数量
fauxqty       --计划生产数量
from icmo    --icmo 为生产任务单

select * from icmo

--感谢小马帮忙提供相关信息。
--fauxcommitqty, --完工辅助数量  即入库的关联数量,包含已审核和未审核的数量
--fheadselfj0194 关联数量(新增字段)

--以下触发器实现更新fauxcommitqty, --完工辅助数量的同时更新fheadselfj0194 关联数量(新增字段)
-- =============================================
-- Author:        <Author,,snomxk>
-- Create date: <2014.04.17>
-- Description:    <同步关联数量>
-- =============================================
CREATE TRIGGER [ICMO_update_fauxcommitqty] on [dbo].[ICMO]
for update
AS
BEGIN
   if update(fauxcommitqty)
   update a
     set a.fheadselfj0194 = b.fauxcommitqty
     from icmo a, inserted b
     where a.finterid = b.finterid

END
GO

--同步关联数量,执行完新增触发器语句再执行Update语句同步数据
update icmo set fheadselfj0194 = fauxcommitqty