Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: PLS/SQL: OK to use EXIT in a cursor FOR LOOP ??
A copy of this was sent to "Genesis" <rindner_at_wwa.com>
(if that email address didn't require changing)
On Tue, 22 Jun 1999 18:52:37 -0500, you wrote:
>Guys,
>
>Before you put down Steve Feuerstein, try to use "for .... loop" with cursor
>having "select .... for update" option on 10,000,000 rows table.
>
>Regrards,
>Gene
>
for x in ( select * from a10million_row_table for update ) loop
...
end loop;
will perform IDENTICALLY to
declare
cursor c1 is select * from a10million_row_table for update; begin
open c1;
loop
fetch c1 into rec; exit when c1%notfound; ...
Only one of them takes heaps more code to write :)
They are the same.
Nothing against Steve -- he does great stuff. Its all a matter of style and preference.
>Kenneth C Stahl wrote in message <376901E0.60FDC704_at_lucent.com>...
>>That is a perfectly valid way to do what you describe. Steve Feuerstein,
>the
>>author of the O'Reilly book "Oracle PL/SQL Programming" says that it is
>poor
>>practice and touts the open/fetch/close scenario, but he seems to have a
>>fundamental lack of understanding that the advantages of using cursor "for"
>>loops outways any "computer weenie" complaints that exiting from a cursor
>>"for" loop amounts to a "goto".
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Jun 23 1999 - 06:59:30 CDT