sybase游标问题
declare @s varchar(8000)declare tb cursor for
select s = 'select * from cheshou '
open tb
fetch tb into @s
while @@sqlstatus=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate cursor tb
执行后出错如下:
Server Message:Number7344, Severity15
Line 7:
DECLARE CURSOR must be the only statement in a query batch.
Server Message:Number11721, Severity15
Line 11:
Global variables not allowed as defaults.
找了半天也没找出原因,各位大侠能否告诉我一下是什么问题,谢谢了!:'( 参考一下,你的不知道处理了啥数据
declare @temp_shop varchar(40)
declare cur_shop cursor for
select ORGAN_ID
from F_SALE_DEPT
where ORGAN_ID LIKE "2%"
OPEN cur_shop
fetch cur_shop into @temp_shop
while @@sqlstatus = 0
begin
exec up_accrpt_zyposinout @arg_year,@arg_prd,"",@temp_shop,"n","y"
fetch cur_shop into @temp_shop
end
close cur_shop
DEALLOCATE cursor cur_shop
页:
[1]