首页 新闻 会员 周边 捐助

这个触发器有问题吗

0
[待解决问题]

USE [PMS]
GO
/****** Object:  Trigger [dbo].[tr_TaskInfo_Update]    Script Date: 06/08/2013 20:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tr_TaskInfo_Update]
ON [dbo].[TaskInfo]
AFTER UPDATE
AS
BEGIN TRANSACTION
   DECLARE @OldIsFinish BIT
   DECLARE @NewIsFinish BIT
   DECLARE @PlanId INT
   DECLARE @Count INT
   SELECT @NewIsFinish=IsFinish,@PlanId=PlanId FROM INSERTED
   SELECT @OldIsFinish =IsFinish FROM DELETED
   IF(@PlanId<>0 AND @NewIsFinish<>@OldIsFinish)
  BEGIN
   IF(@OldIsFinish=1)
    BEGIN
     UPDATE dbo.PlanDetailInfo SET IsFinish='0' WHERE PlanDetailId=@PlanId
    END
      ELSE
    BEGIN
     SELECT @Count=COUNT(*) FROM dbo.TaskInfo  WHERE IsFinish='0' AND PlanId = @PlanId AND IsView='1'
     IF(@Count=0)
          BEGIN
       UPDATE dbo.PlanDetailInfo SET IsFinish='1' WHERE PlanDetailId=@PlanId
       END
    END
   
  END
 IF(@@ERROR<>0)
  ROLLBACK TRAN
 ELSE
  COMMIT TRAN

问题补充:

  SELECT @Count=COUNT(*) FROM dbo.TaskInfo  WHERE IsFinish='0' AND PlanId = @PlanId AND IsView='1'

把这个select语句中的条件去掉两个就能运行,不去掉就运行不了

尚飞龙的主页 尚飞龙 | 初学一级 | 园豆:197
提问于:2013-06-08 21:40
< >
分享
所有回答(1)
0

去掉和不去掉 都可以编译通过啊  不知道你说的什么问题

失忆的烟 | 园豆:8 (初学一级) | 2013-06-24 18:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册