Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> How to use a different cursors in a single FOR loop

How to use a different cursors in a single FOR loop

From: Lee <lduhl_at_corp.realcomp.com>
Date: 3 Nov 2004 14:29:33 -0800
Message-ID: <719532c5.0411031429.76d5d0b2@posting.google.com>


I have a procedure that is based off of a FOR LOOP. I would like to be able to use this same procedure for a couple of diffenet situations. The processing within the FOR loop is always the same, the only thing that is different is the cursor the FOR LOOP is based on.

I would like to know if there is a way to change the cursor that is used within the FOR LOOP depending on the specific situaion.

For example
FOR x IN (SELECT * from MyTable WHERE Col1 = 'ABC') LOOP
.... Handle Processing

END LOOP; Under a different situation I may want do to the following: FOR x IN (SELECT * from MyTable WHERE Col1 = 'DEF' AND Col2 = 1) LOOP
.... Handle the same processing mentioned above.
END LOOP; I've tried creating a func within a package that returns a ref cursor that is dynamically generated, but this does not work becuase the FOR LOOP requires an explicit cursor.

I guess one opton would be to move the "Processing Logic" to a seperate func/proc in the package and have set of overloaded funcs/procs as a wrapper. Within each of these overloaded funcs/procs I would have the specific "FOR LOOP" declared.

Any info you can supply would be greatly appreciated.

Thanks
Lee Received on Wed Nov 03 2004 - 16:29:33 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US