Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL Help
Just curious, but would there be a problem with opening a single select that uses your two predicates with an OR between them? If there is something special having to be done on each row you could use an if statement based upon the salary value and behave slightly differently with each. This might work better as I suspect you're getting a full table scan in both cases. Not sure if this will work depending on the details of your app, but it might be worth a thought.
Rich
"Thomas J. Kyte" <tkyte_at_us.oracle.com> wrote in message
news:8iob13$jcn$1_at_nnrp1.deja.com...
> In article <8io9di$i2q$1_at_nnrp1.deja.com>,
> Ethan Post <epost1_at_my-deja.com> wrote:
> > 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.
> >
> ref cursors are the answer. Here are 2 examples. one is a procedure
> that figures out which query it wants to run and then does it. the
> other is a procedure that lets someone pass a cursor they opened to it
> which it will then process...
>
>
>> ops$tkyte_at_8i>
> ops$tkyte_at_8i>
>
> >
>> ops$tkyte_at_8i>
> ops$tkyte_at_8i>
>
>
>
>> ops$tkyte_at_8i>
> ops$tkyte_at_8i>
>
> >
![]() |
![]() |