Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes oracle record fetch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "oracle record fetch" Watch "oracle record fetch" New topic

oracle record fetch

sugath nelabhotla

Joined: Apr 24, 2006
Posts: 4
Hi, i know that when we use select * from table where rownum < 100, we get the first 100 records from the table. Is there any way that I can get the next 100 records from the table? rownum > 100 does not work. My table is not indexed and does not a primary key. Currently I am sorting the table and keeping track of 101 record id and then triggering the second batch query using the rec id.

Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
You can't use rownum with > operator. What you are trying to do is pagination.

select * from
(select rownum as row_seq, t.* from table t where rownum < :upperbound )
where row_seq between :lowerbound and :upperbound
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

I would recommend that you read about analytical functions of oracle. RANK DENSE_RANK , and ROW_NUMBER would help you much in this regard.


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I agree. Here's the link:
subject: oracle record fetch
It's not a secret anymore!