游标问题?请指教
mbjxj 2000-03-30 04:39:00 下面是一段SQL程序验证分析时提示如下错误请专家们解答,多谢!!
declare my_curr scroll cursor for select 收入, 支出, 余额 from 现金日报表
open my_curr
declare @remainder decimal(9)
declare @remainder1 decimal(9)
declare @income decimal(9)
declare @income1 decimal(9)
declare @out decimal(9)
declare @out1 decimal(9)
declare @count int
fetch first from my_curr into @income ,@out, @remainder1
SET @count=@@cursor_rows
while @count >=0
begin
fetch relative 0 from my_curr into @income1,@out1,@remainder1
fetch next from my_curr into @income ,@out, @remainder
set @remainder=@remainder1+@income-@out
update 现金日报表
set 余额 = @remainder
where current of my_curr
set @count=@count-1
select @remainder,@remainder1,@income,@out
end
close my_curr
deallocate my_curr
运行时错误:
Server: Msg 16930, Level 16, State 1, Line -1074283898
The requested row is not in the fetch buffer.
The statement has been terminated.
----------- ----------- ----------- -----------
3 3 345 345
(1 row(s) affected)
Server: Msg 16930, Level 16, State 1, Line 17
The requested row is not in the fetch buffer.
The statement has been terminated.
----------- ----------- ----------- -----------
3 3 345 345
(1 row(s) affected)