PL/SQL For-loops vs explicit cursors

From: Eric Hartzenberg <Eric_at_erichome.demon.co.uk>
Date: 1995/07/23
Message-ID: <61204309wnr_at_erichome.demon.co.uk>#1/1


Brothers & Sisters in Oracle:  

 declare cursor mycursor is select * from mytable;

 Method 1:

    for c1 in mycursor loop

        ...
        ...

    end loop;

 Method 2:

    open mycursor;
    loop

      fetch mycursor into xyz;
      exit when mycursor%notfound; 

...
...

    end loop;
    close mycursor;       

The 2nd method appears more long-winded although more universally used, even to the extent of doing single-row fetches where a simple in-line 'select ...into' would have the same effect.
I find method 1 more concise & readable. Does anyone have any strong feelings on the subject? This may appear a little feeble to you, but it's been bugging me for months!

-- 
 _______________________________________________________________
|      Eric Hartzenberg      |'Net  : eric_at_erichome.demon.co.uk |
| Oracle Analyst/Programmer  | CIS  : 100073,21                 |
|____________________________|__________________________________|
Received on Sun Jul 23 1995 - 00:00:00 CEST

Original text of this message