Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> PL/SQL Help
Someone please provide a somewhat more elegant solution to the problem in the following sample code. The problem lies in the fact that the exact same work needs to be done on both cursors and the line "Do Some Work" is duplicated in the code. I would like to re-use the loop and somehow pass the cursor into the procedure. I played around with REF CURSOR and such but haven't really found what I'm looking for. For the moment I'm just using 1 cursor and using a union statement to tie the SQL together but that is not very elegant.
PROCEDURE Test IS
c_cursorA IS SELECT name from emp where sal > 30000;
c_cursorB IS SELECT name from emp where sal < 30000
and start_dt = '01-Jan-00'
BEGIN For lv_rec in c_cursorA LOOP
Do Some Work;
END LOOP;
For lv_rec in c_cursorB LOOP
Do Some Work;
END LOOP;
END Test;
-- Thanks! - Ethan http://www.freetechnicaltraining.com http://www.gnumetrics.com Sent via Deja.com http://www.deja.com/ Before you buy.Received on Tue Jun 20 2000 - 00:00:00 CDT