如何判断游标是否存在?
--检验全局游标cur的存在性,局布的为local,如果存在就删除
if cursor_status('global','cur')<>-3
begin
close cur
deallocate cur
end
定义游标
Declare s_cur cursor for
select ID
FROM CriterionClassify
打开游标
OPEN s_cur
FETCH NEXT FROM s_cur into @rows
循环结果集
WHILE @@FETCH_STATUS = 0
BEGIN
exec UP_CriterionClassify_GetChildList @rows
--select @idlist=isnull(@idlist,'')+@id +',' --字符串相加
FETCH NEXT FROM s_cur into @rows
end
CLOSE s_cur
DEALLOCATE s_cur