Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PLS/SQL: OK to use EXIT in a cursor FOR LOOP ??

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

From: Mark Gumbs <mgumbs_at_nospam.hotmail.com>
Date: Mon, 14 Jun 1999 15:54:33 +0100
Message-ID: <37651551.0@145.227.194.253>


If the table is large, that may be a good solution.

If it is a smaller (or quick) table..

SELECT a, b, C
FROM my_table mt1
where 5 > (select count(*) from my_table mt2 where mt1.a < mt2.a) ORDER BY d

Andy Hardy wrote in message ...
>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;
>
>--
>Andy Hardy. PGP key available on request
>===============================================================
Received on Mon Jun 14 1999 - 09:54:33 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US