是游标里面嵌套游标吗?数据量大的话最好不要采用这种方法!
这是SQL SERVER的:
DECLARE CUR_1 CURSOR--第一层游标声明
FOR SELECT C_1,C_2 FROM TABLENAME
OPEN CUR_1
FETCH NEXT FROM CUR_1 INTO @C_1,@C_2
WHILE @@FETCH_STATUES<>0
BEGIN
DECLARE CUR_2 CURSOR--第二层游标声明
FOR SELECT A_1,A_2 FROM TABLENAME
OPEN CUR_2
FETCH NEXT FROM CUR_2 INTO @C_1,@C_2
WHILE @@FETCH_STATUES<>0
BEGIN
.....
.....
FETCH NEXT FROM CUR_2 INTO @A_1,@A_2--二层循环
END
CLOSE CUR_2
DEALLOCATE CUR_2
FETCH NEXT FROM CUR_1 INTO @C_1,@C_2--一层循环
END
CLOSE CUR_1
DEALLOCATE CUR_1
怎么才叫简单游标,上面的是游标的基本框架,也就是: 声明游标declare 打开游标open 游标循环fetch next from....... 关闭游标close 释放游标deallocate