Re: PLS/SQL: OK to use EXIT in a cursor FOR LOOP ??

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 14 Jun 1999 14:28:15 GMT
Message-ID: <376c1124.8322226_at_newshost.us.oracle.com>


A copy of this was sent to Andy Hardy <aph_at_ahardy.demon.co.uk> (if that email address didn't require changing) On Mon, 14 Jun 1999 15:13:47 +0100, you wrote:

>Hello,
>
>I used a cursor FOR LOOP to work my way through some ordered data. I now
>want to limit the number of rows considered using something like ROWNUM.
>However, as ROWNUM is considered before ORDER I cannot simply add it to
>the query.
>
>I *could* create a FOR LOOP with an EXIT clause based on the %ROWCOUNT,
>but wonder if this is the *correct* way to do this or would it upset the
>Oracle cursor management?
>
>Any thoughts?
>
>E.G
>
>CURSOR my_csr
>IS
>SELECT a, b, C
> FROM my_table
> ORDER BY d
>;
>
>FOR v_data IN my_cursor LOOP
> EXIT WHEN my_cursor%ROWCOUNT > 5;
> -- do the real work
> --
>END LOOP;
Thats exactly the way to do it...

See http://www.oracle.com/ideveloper/ for my column 'Digging-in to Oracle8i'... Mirrored (and more current) at http://govt.us.oracle.com/~tkyte/

Current article is "Fine Grained Access Control", added June 8'th  

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 Mon Jun 14 1999 - 16:28:15 CEST

Original text of this message