sql - Passing different (multiple) cursors to the same For Loop -


Edit for better explanation:


1/28/09 Added: I simplified To make the code easier to explain, but the selection statements are very long and complex, and secondly, the first cursor is dependent on the first meaning and is stopped by it and the other option inserted actually looks first. Where inserts as part of the section.

That is why I have to use the loop once and there should not be any combination of selection. I need to run them, when I call them in order, which I want to call them, which brings me back to my original question, still using a different cursor to reuse a loop ?

Thanks again


I am creating a package (Oracle 10) in which I have 4 separate selection statements (possibly more to come) For all I create a cursor and get my data. Now generally I take the data and the loop is constructed and everything is fine.

My problem is that I have four different choices, but I want to use the loop again so that I have to use cursor C2. With the same loop as well as C3, and C4, all the cursors get different information from different selections, but they are all going in the same table with my included statement in the loop. Apart from this, I can not be involved in all the selections together, they have to be done with a commitment after each loop

I have made an example with 4 loops down but as you can see That they are all the same, the only difference is: for R in C1 loop, for R in C2 loop ... I think there should be no room for reuse of loop. I had some ideas, none of which used to work.

  select cursor c1 info_a, info_b from table_x where info_g = 77; Cursor C2 selection-one, from info_b to table_x where info_g = 88; Cursor C3 is A-A, table_y from info_b where info_j = 88; Cursor C4 is A-A, table_y from info_b where info_j = 99; Start for R in c1 loop entry in Fun_table (good_info, boring_info) values ​​(r.info_a, r.info-b); End loop; Committed; For R in C2 loop entry in Fun_table (good_info, boring_info) values ​​(r.info_a, r.info-b); End loop; Committed; Fun_table (good_info, boring_info) value (r.info_a, r.info-b) in inserting c3 loop for R; End loop; Committed; For R in C4 loop entry in Fun_table (good_info, boring_info) values ​​(r.info_a, r.info-b); End loop; Committed; End;  

Hope this makes more sense and thanks

I edited and then some answers came .. sorry. Originally looked at something like this:

  Cursor C1 som_monfo, select some_table from other_info where where some_thing = 'xyz'; Cursor C2 some_nifo, choose some_table from other_info, where some_thing = 'abc'; Fun_table (good_info, boring_info) value (r.some_info, r.other_info) in inserting a c1 loop for; End loop;  

Or just do it:

  cursor c1 Select Info_a, from info_b to table_x where info_g IN (77, 88) unison all information -A, info_b from table_y where info_j IN (88, 99); Start for R in c1 loop entry in Fun_table (good_info, boring_info) values ​​(r.info_a, r.info-b); End loop; Committed; End;  

Comments