Please fine below code for opening one cursor under another cursor.
I may be missing some syntax but the idea is similar.
open cursor1;
fetch cursor1
into v_p_id,v_o_id,v_e_count;
set p_stat1=SQLSTATE;
if ( p_stat1 = '02000') then
set loop2 = 1;
end if;
while (loop2 = 0) do
open cursor2;
fetch cursor2
into v_set_id,v_episode_count_by_set;
set p_stat2=SQLSTATE;
if ( p_stat2 = '02000' ) then
set loop3=1;
while(loop3=0) do
set of statements....
fetch cursor2 into ...
end while ;
close cursor1;
fetch cursor1 into ...;
close cursor2;
end while;