Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cursor -- passing where clause string as parameter?

606275Aug 13 2009 — edited Aug 13 2009
I do not believe this is possible, but just want to make sure.

I have several cursors that select the same columns from the same table, only the WHERE clause changes. I was looking into consolidating the cursors into perhaps one cursor, since the cursor itself is quite large in the code (due to sorting cases, etc.). I was wondering if one could do the following:

Have a cursor defined as cursor_name (param1)...

Then, when opening the cursor, passing a string to the cursor so as to switch the WHERE clause each time.

I.e.:
Cursor cursor_name (param1) IS SELECT ... FROM ... WHERE param1;

When I attempt to do this in my PL/SQL code, I obviously receive an error. Which leads me to believe that such a thing isn't possible? Any other suggestions then of how I can consolidate my similar cursors?

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2009
Added on Aug 13 2009
3 comments
1,173 views