Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle SELECT statement for SPECIFIC row?
In article <8abger$rp7$1_at_nnrp1.deja.com>,
jmckwood_at_my-deja.com wrote:
>
Read relational database theory. One of the definitions:
The content of the tuple is the only way to address the tuple.
That actually means that you CAN'T address the row in the table by
row number, because row number doesn't exist anywhere in the table.
It also means that rows are retrieved in random order from the
database (not completely true, but no order is guaranteed unless you
use order by). The rownum function provided by Oracle counts rows in
the CURRENT SELECT STATEMENT ONLY. That's why rownum = 5 doesn't
return anything.
>
> Due to architectural limitations of the application, I need to be able
> to select individual rows in a database table, based on their "row
> number," preferably using the SELECT statement. How do I do this?
>
> For example, if database table ACCOUNTS has 250 rows, e.g.
> select count(*) from ACCOUNTS == 250
>
> I need to be able to do the following:
> for index = (1..250)
> select * from ACCOUNTS where ROWNUM = index
>
> However, when I try this, the select statement works ONLY when
> rownum == 1. If I try rownum == 5 or any other value, I get nothing
> back.
>
> Is there a way to retrieve SPECIFIC rows, by row number, without
> knowing the contents of each row?
>
> Thanks for helping ...
> Jim Wood
> jmwood_at_unispheresolutions.com
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Mar 16 2000 - 13:17:05 CST
![]() |
![]() |