Re: Top 5 Hitters?
Date: 1995/08/11
Message-ID: <40e9nv$l7_at_ixnews3.ix.netcom.com>#1/1
elhuilli_at_ifremer.fr (Eric L'Huillier, Ifremer PDG-DGD-DGO-INGE) wrote:
>In article <Pine.SOL.3.91.950729162615.8751A-100000_at_eniac>, Frank Talbott <talbof@eniac> says:
>Hi,
>Why don't you use a rownum condition in the where clause instead
>of using a for loop ?
>Try something like
>cursor c1 is
>select * from table where conditions and rownum <=5;
>open c1;
>loop
> fetch c1;
> exit when c1%notfound;
> ...
>end loop;
>You get back only the row you want and save your network.
rownum won't work with an ORDER BY clause. It'll only sort the first 5 rows in the table. He wants to sort first, then get the first 5 rows of the result.
I think the only efficient way of doing what he wants is with a cursor in a PL/SQL block.
-- Chuck Hamilton chuckh_at_ix.netcom.com If at first you don't succeed, sky-diving isn't for you.Received on Fri Aug 11 1995 - 00:00:00 CEST