问题描述
- 存储过程 游标 while @@fetch_status=0 死循环
-
这段存储过程加了 while @@fetch_status=0 后会进入死循环 注释这行就可以运行成功 求大神指导declare @systems varchar(200) --查询的此服务的其他消费系统 begin--7 set @out=@out+'<TargetSysList>' declare test cursor for select c_user_number from ESB_CONSUME_SYSTEM where c_code = @fid and c_is_examine='1' open test fetch next from test into @systems --while @@fetch_status=0 begin --10 if(@systems<>@system) begin --8 set @out=@out+'<TargetSysCode>'+@systems+'</TargetSysCode>' end --8 end--10 close test deallocate test begin --9 set @out=@out+'</TargetSysList></MGREntry>' end --9 set @out1=@out end--7
解决方案
你不取下1行,当然@@fetch_status永远等于0啊!
fetch next from test into @systems
while @@fetch_status=0
begin --10
if(@systems<>@system)
begin --8
set @out=@out+''+@systems+''
end --8
** fetch next from test into @systems**
end--10
解决方案二:
存储过程/使用while和游标
oracle编程 if, for , while, loop, 存储过程,触发器,游标演示
sql server 函数,存储过程,游标以及while和if语句的嵌套使用
时间: 2024-09-17 03:46:45