运用SQL触发器解决办理流程中表之间关联状态变化问题

CREATE TRIGGER [mghm_ly] ON [dbo].[xs_lyrelationyx]
FOR Update
AS
Declare @dhhm varchar(11)
declare cc1 cursor for
select dhhm from inserted
open cc1
while 1=1
begin
fetch cc1 into @dhhm
if @@fetch_status <>0 break
update xs_lyrelationyx set rec_status='T' where dhhm=@dhhm and reccnt=reccnted
update xs_lyrelationyx set rec_status='P' where dhhm=@dhhm and reccnt>reccnted and reccnted>=1
End
close cc1
deallocate cc1

你可能感兴趣的:(sql)