CREATE OR REPLACE PROCEDURE test AS CURSOR cur_inner IS select * from test_table1 where x = x; CURSOR cur_outer IS select * from test_table2; BEGIN OPEN cur_outer; <<fetch_outer_loop>> LOOP FETCH cur_outer INTO x, y, z; exit fetch_outer_loop when NOT cur_outer%found; OPEN cur_inner; <<fetch_inner_loop>> LOOP FETCH cur_inner INTO x, y, z; /* How do I limit the inner loop to just to values liited by the WHERE clause in the CURSOR cur_inner above? Break the loop and then get the next WHERE clause value from the Outer Loop Cursor. -- process data using values fetched from cur_inne r*/ exit fetch_inner_loop when NOT cur_inner%found; END LOOP fetch_inner_loop; CLOSE cur_inner; insert into result_table (a, b, c ) values (a, b, c ); commit; END LOOP fetch_outer_loop; CLOSE cur_outer_freq; END test;
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.