huhaifeng123 2015-09-22 02:04 采纳率: 100%
浏览 5589
已采纳

存储过程 游标 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条回答 默认 最新

  • sliang733 2015-09-22 02:12
    关注

    你不取下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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)