SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter TRIGGER tri_jr_AutoUpdateASN
ON dbo.SEOutStock
FOR UPDATE
AS
set XACT_ABORT on
if update(FCheckerID)
begin
declare @FID as int
declare @billNo as nvarchar(20)
declare @oldFCheckerID as int
declare @newFCheckerID as int
SELECT @oldFCheckerID=isnull(FCheckerID,0) FROM deleted
SELECT @billNo=FbillNo, @newFCheckerID=isnull(FCheckerID,0) FROM inserted
declare @sql as nvarchar(200)
--set @sql=' select @p=count(HOST_INPT_ID) from openquery(wmtst_pos,''select HOST_INPT_ID from inpt_asn_hdr where SHPMT_NBR ='''''+ 'I'+ @Billno+''''''')'
--declare @p int
--exec sp_executesql @sql,N'@p int output',@p output
if @oldFCheckerID=0 and @newFCheckerID>0 --审核
begin
--if @p=0 --新增
-- begin
begin distributed tran
exec pr_jr_ImportASN @billNo,11,'02'
commit tran
-- end
--if @p>0 --修改
-- begin
-- exec pr_jr_ImportASN @billNo,11,'01'
-- end
end
/* if @oldFCheckerID>0 and @newFCheckerID=0 --反审核
begin
exec pr_jr_ImportASN @billNo,11,'03'
end
*/
end
GO