|
楼主 |
发表于 2012-5-7 14:58:38
|
显示全部楼层
deerjam 发表于 2012-5-3 15:37
看这情况应该没什么冲突,说不好。不过可以建议你将这两个触发器合到一起
这样行吗?
CREATE TRIGGER [dbo].[trig_fin-invprice ]
ON [dbo].[inventory]
FOR INSERT,UPDATE
AS
BEGIN
DECLARE @cInvCode VARCHAR(20),@cInvCCode VARCHAR(12),@cInvDefine6 VARCHAR(60),@cInvDefine1 VARCHAR(12),@cSRPolicy VARCHAR(12)
SELECT @cinvcode = cinvcode
FROM inserted
SELECT @cInvCCode = cinvccode,@cInvDefine6 = cinvdefine6,@cSRPolicy = cSRPolicy,@cInvDefine1 = cinvdefine1
FROM inventory
WHERE cinvcode = @cinvcode
BEGIN
BEGIN
IF NOT EXISTS (SELECT cinvdefine1
FROM Inventory
WHERE cinvdefine1 = @cSRPolicy)
UPDATE Inventory
SET cInvDefine1 = @cSRPolicy
FROM Inventory
END
END
IF LEFT(@cInvCCode,2) = '12'
AND @cInvDefine6 = '外协'
BEGIN
IF NOT EXISTS (SELECT cinvcode
FROM fin_invprice
WHERE cinvcode = @cinvcode)
BEGIN
INSERT INTO fin_invprice(cinvcode)
VALUES (@cinvcode)
END
END
END
|
|