Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: loop
Stjepan Brbot wrote:
>
> "Connor McDonald" <connor_mcdonald_at_yahoo.com> wrote in message
> news:3D4BA164.67D9_at_yahoo.com...
> > Stjepan Brbot wrote:
> > >
> > > What is better:
> > >
> > > FOR xy IN curXY LOOP
> > > ...
> > > END LOOP;
> > >
> > > or
> > >
> > > OPEN curXY;
> > > LOOP
> > > FETCH curXY INTO xy;
> > > IF curXY%NOTFOUND THEN
> > > EXIT;
> > > END IF;
> > > ...
> > > END LOOP;
> > >
> > > --
> > >
> > > Stjepan Brbot
> >
> > The first because
> >
> > a) its simpler to read
> > b) its less code
> > c) its faster
> >
> > If you don't need any cursor attributes through the loop, you can also
> > code
> >
> > for i in ( select ...
> > from ... ) loop
> > ...
> > end loop;
>
> I thought that too becuse this is the same situation like with FOR..NEXT
> vs. WHILE..WEND loops in other programming languages. But I wasn't sure
> because I had found a lot of code from very expirienced developers using
> the second way with %NOTFOUND.
>
> --
>
> Stjepan Brbot
You'll find a lot of people saying that explicity declaring cursors is faster than not, ie they will claim that
cursor X is select ...
open
fetch
close
is faster then
select ..
into variable
from table
Ask them to prove it...they'll struggle :-)
hth
connor
-- ============================== Connor McDonald http://www.oracledba.co.uk "Some days you're the pigeon, some days you're the statue..."Received on Sun Aug 04 2002 - 10:27:42 CDT