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 -> first N rows with a cursor

first N rows with a cursor

From: Jeff Greif <jmg_at_spam-me-not.trivida.com>
Date: 2000/05/11
Message-ID: <sqES4.96$Ubs.589859@dca1-nnrp1.news.digex.net>#1/1

As has been pointed out on this newsgroup several times recently,

    select * from
(select ename from emp group by ename order by ename desc)
    where rownum <= 10;

retrieves the first 10 rows from the inner query. However, if you try to open a cursor on this statement in Oracle 8.1.5.0.0, using

declare
  cursor ecurs is
    select * from
(select ename from emp group by ename order by ename desc)
    where rownum <= 10;
begin
...
end

you get an error:
 PLS-00103: Encountered the symbol "ORDER" when expecting one of   the following:
  . ( ) , * @ % & - + / mod rem with an exponent (**) group   having intersect minus start union where connect ||   The symbol ")" was substituted for "ORDER" to continue.

Is there a known way around this? Is there some kind of incompatibility between PL/SQL and SQL?

Thanks in advance,
Jeff Received on Thu May 11 2000 - 00:00:00 CDT

Original text of this message

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