存储过程 游标 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