一个关于游标的@@FETCH_STATUS问题
OPEN WK_SELL_DAY_CURSOR
WHILE (@@FETCH_STATUS = 0) BEGIN
FETCH NEXT FROM WK_SELL_DAY_CURSOR Into
@CUSTOMER_CODE,@SIMPLE_NAME,@DEBT_PERIOD,@DEBT_AMOUNT
OPEN WK_SELL_DAY_CURSOR
WHILE (@@FETCH_STATUS = 0) BEGIN
FETCH NEXT FROM WK_SELL_DAY_CURSOR Into @ACCOUNTSET_CODE
...........
END
END
@@FETCH_STATUS是最近一次的FETCH结果,那么有什么办法可以解决嵌套游标@@FETCH_STATUS值的问题???让@@FETCH_STATUS为当前层的游标的@@FETCH_STATUS值??有什么解决办法吗?
等待高人回答,谢谢.
------解决方案--------------------这个不用吧,嵌套游标在循环时都有BEGIN 和end结束的,我就用了,没什么问题啊
------解决方案--------------------OPEN WK_SELL_DAY_CURSOR
WHILE (@@FETCH_STATUS = 0) BEGIN
FETCH NEXT FROM WK_SELL_DAY_CURSOR Into
@CUSTOMER_CODE,@SIMPLE_NAME,@DEBT_PERIOD,@DEBT_AMOUNT
OPEN WK_SELL_DAY_CURSOR
WHILE (@@FETCH_STATUS = 0) BEGIN
FETCH NEXT FROM WK_SELL_DAY_CURSOR Into @ACCOUNTSET_CODE
...........
END
CLOSE WK_SELL_DAY_CURSOR --加了这两句
DEALLOCATE WK_SELL_DAY_CURSOR --加了这两句
END
CLOSE WK_SELL_DAY_CURSOR --加了这两句
DEALLOCATE WK_SELL_DAY_CURSOR --加了这两句