--Declare outer cursor
declare outer_cursor cursor for
select id from table
--Declare inner cursor as a variable
declare @inner_cursor cursor
open outer_cursor
fetch next from outer_cursor into @id
while(@@FETCH_STATUS=0)
begin
-- Few statements
declare @cartid bigint
declare @qty bigint
set @inner_cursor = cursor for select id,qty from cart where productid=@id open @new_count
fetch next from @inner_cursor into @cartid, @qty while(@@FETCH_STATUS=0)
fetch next from @inner_cursor into @cartid, @qty while(@@FETCH_STATUS=0)
begin
--Few Statements
end
end
hmmm... good work :)
ReplyDelete