Re: Select ROWID with a criteria

From: Tony <andrewst_at_onetel.net.uk>
Date: 1 May 2003 09:20:34 -0700
Message-ID: <c0e3f26e.0305010820.61f82367_at_posting.google.com>


odd.morten.sveas_at_accenture.com (Odd Morten Sveås) wrote in message news:<4306a83.0305010211.30dff11c_at_posting.google.com>...
> > > You can NOT "select a range of rows using rowid number.
> Sure you can.
>
> SELECT EMP_NAME
> FROM EMP
> WHERE rowid between chartorowid(10) and chartorowid(1000)
>
> However you wount get any row here. The rowid can be represented as a
> 9(or something) char long string, ant it increases for every insert.
> You can get the char reprenentation of the rowid by useing the
> rowidtochar(rowid) function.
>
> Regards
> Odd M

I'm pretty sure that by this:

SELECT EMP_NAME FROM EMP WHERE ROWID(EMP) >= 10 AND ROWID(EMP) <= 1000;

the questioner really meant "get me rows 10 to 1000 from table EMP". And of course, that would assume some kind of ordering, e.g. by EMP_NAME. In which case the answer would be:

SELECT EMP_NAME FROM
( SELECT EMP_NAME, ROWNUM AS RN FROM
  ( SELECT EMP_NAME FROM EMP
    ORDER BY EMP_NAME
  )
)
WHERE RN BETWEEN 10 AND 1000; Received on Thu May 01 2003 - 18:20:34 CEST

Original text of this message