I want to declare something like:
declare cursor1 cursor for select ...
open cursor1
while @@fetch_status = 0
begin
declare cursor2 cursor for select * from aaa where f1 = <variable_of_cursor_1>
open cursor2
-- checkpoint B
while @@fetch_status = 0
begin
end
close cursor2
deallocate cursor2
end
close cursor1
deallocate cursor1
-----------------------------------------
@@fetch_status at checkpoint B always returns -1
Is it possible to declare such a nested cursor declaration?
declare cursor1 cursor for select ...
open cursor1
while @@fetch_status = 0
begin
declare cursor2 cursor for select * from aaa where f1 = <variable_of_cursor_1>
open cursor2
-- checkpoint B
while @@fetch_status = 0
begin
end
close cursor2
deallocate cursor2
end
close cursor1
deallocate cursor1
-----------------------------------------
@@fetch_status at checkpoint B always returns -1
Is it possible to declare such a nested cursor declaration?