发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
CREATE TRIGGER onPlanMo1Delete ON [dbo].[PlanMO1]
FOR DELETE
AS
declare @MoNo varchar(20),
@line smallint;
declare #aa cursor for select mono,line from deleted
open #aa
fetch next from #aa into @mono,@line
while @@fetch_status=0
begin
IF (SELECT PKQty+PKQtyL FROM PlanMO2 WHERE PMONO=@MoNo AND PMoLine=@line)>0
Begin
rollback transaction
return
end
IF (SELECT PKQty+PKQtyL FROM PlanMO2 WHERE PMONO=@MoNo AND PMoLine=@line)=0
Begin
DELETE from PlanMo2 where PMONO =@MoNo AND PMoLine=@Line
end
fetch next from #aa into @mono,@line
end
close #aa
deallocate #aa
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。