while @dj_sort <> @max_sort begin set @count=@count+1 FETCH NEXT FROM djsort_cursor into @duiydjbh,@dj_sort end ----@dj_sort 的初始值>@max_sort ,所以不可能有@dj_sort = @max_sort
游标取值循环取值的时候必须要加上@@fetch_STATUS=0
应该是游标的结果集走到底了 因为没有@@fetch_status的判断 条件@dj_sort仍然小于@max_sort 于是继续fetch next 至于@dj_sort得到什么值就不清楚了 可能是null吧
begin
set @count=@count+1
FETCH NEXT FROM djsort_cursor into @duiydjbh,@dj_sort
end
----@dj_sort 的初始值>@max_sort ,所以不可能有@dj_sort = @max_sort
------------
那就要保证dj_sort在满足条件前需要经过的循环<=结果集的行数