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: How to limit rows in PL/SQL?

Re: How to limit rows in PL/SQL?

From: Keith Jamieson <Keith.Jamieson_at_phoenix.ie>
Date: Thu, 26 Apr 2001 17:01:35 +0100
Message-ID: <9c9gf0$8em$1@kermit.esat.net>

You can use and rownum <= maxno_of_rows_wanted, but there are problems when using order by.

Jerry Metz wrote in message <3AE72CCD.F8EA8FD_at_ix.netcom.com>...
>Why don't you just use an explicit cursor and cut off retrieval after the
 first
>fetch?
>
>Richard Piasecki wrote:
>
>> Greetings.
>>
>> This problem has bothered me for some time, and I've finally decided to
 see
>> if anyone else has a solution to it.
>>
>> Is there a way to limit the number of rows Oracle returns in a query? For
>> example, if I execute a query like:
>> SELECT f1 INTO :x
>>
>> and it returns more than one row, I'll get an exception. I've been told
 that
>> other databases (namely Sybase) provide a variable that can be set to
 limit
>> the number of returned rows to a certain number. The solution I've always
>> used in Oracle is to declare a cursor and fetch once from it. Is this the
>> only way in Oracle or does anyone know of another method to use?
>>
>> --- Rich
>
Received on Thu Apr 26 2001 - 11:01:35 CDT

Original text of this message

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