Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: loop
AFAIK there is another advantage of
for... (select ...) loop
..
end loop;
when an exception occurs and you jump out of the loop in above case, cursor (implicit) will be automatically closed in second one, you have to make sure that you close it.
Piotr
Uzytkownik "Connor McDonald" <connor_mcdonald_at_yahoo.com> napisal w
wiadomosci news:3D4D47EE.2142_at_yahoo.com...
> 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
>
>
>
>
>
>
>
![]() |
![]() |