create trigger TR_Delete_pm_WorkCard on pm_WorkCard for delete as if @@rowcount=0 return begin tran update pm_PlanEntry set FDispatchQty=t4.FDispatchQty - t1.FDispatchQty from deleted as t2 join pm_WorkCardEntry as t1 on(t1.fparentid=t2.FInterID) join pm_Plan t3 on(t2.FPlanID=t3.FInterID) join pm_PlanEntry as t4 on(t3.FInterID=t4.fparentid and t1.FRowID=t4.FRowID) if @@error=0 commit tran else rollback tran
ͨ¹ýÕâ¸öÓï¾ä select * from pm_WorkCard as t2 join pm_WorkCardEntry as t1 on(t1.fparentid=t2.FInterID) join pm_Plan t3 on(t2.FPlanID=t3.FInterID) join pm_PlanEntry as t4 on(t3.FInterID=t4.fparentid and t1.FRowID=t4.FRowID)
Äܵõ½Êý¾Ý¡£ if @@rowcount=0 return --ÎÊÌâÊDz»ÊÇÔÚÕâÀÓÐÓÃÂ𣿠¾õµÃÊÇûʲôÓÃ,ºÇºÇ,±¾À´¾ÍÊǺ󴥷¢ÁË