IF OBJECT_ID ('ppSDetail_PPIn','TR') IS NOT NULL
DROP TRIGGER ppSDetail_PPIn;
GO
CREATE TRIGGER ppSDetail_PPIn ON ppSDetail
AFTER INSERT
AS
DECLARE @iBillType INTEGER
DECLARE @cBillCode VARCHAR(100)
SELECT @iBillType=iBillType,@cBillCode=cBillCode FROM Inserted
IF @iBillType = 0
BEGIN
IF EXISTS(SELECT 1 FROM
ppSDetail a
LEFT JOIN
PPInDetailPlace b
ON b.cbillcode=a.cBillCode
AND a.cPaperCode=b.cpapercode
WHERE a.cBillCode=@cBillCode AND b.cpapercode IS NULL)
BEGIN
RAISERROR ('触发器:确认入库时出现入库单(" + @cBillCode + ")不存在的纸写入了实物账中的问题,请找系统管理员报告这个错误!', 16, 1);
ROLLBACK TRANSACTION;
RETURN
END
END