Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: getting X rows at a time via JDBC (i.e. no cursors)

Re: getting X rows at a time via JDBC (i.e. no cursors)

From: Otis Gospodnetic <otis_at_my-deja.com>
Date: 2000/04/11
Message-ID: <8d08fq$l23$1@nnrp1.deja.com>#1/1

In article <38f37e60.18778572_at_news>,
  See Message body for real address wrote:
>
>
> The only way I know, without cursor processing, to get a limited
 number of
> records is to use
> where ROWNUM ( not rowid) < some_number 1 greater that the # of rows
you want...

Hi,

Hm, that's closer than ROWID :)

But I realized later, I could not use ROWID nor ROWNUM because I don't want to go through _all_ the data but rather select data that matches specific values.
For example:

select * from nm_user_info where user='joe';

I could not do:

select * from nm_user_info where user='joe' and rowid between 1 and 10;

nor could I do:

select * from nm_user_info where user='joe' and rownum between 1 and 10;

I can't do the latter two because rows that match "user='joe'" part are not necessarily one after the other (other users' data may be between joe's rows) so "between 1 and 10" wouldn't work (there may be only 4 rows between rowid/rownum 1 and 10 for example).

I saw some Oracle's docs that say that there is getRow() method in java.sql.ResultSet and that may be what I need, but my Oracle JDBC driver (the one that comes with Oracle 8i version 8.1.5) doesn't have that method :(

Still looking for help :)

Thank you,

Otis

> Otis Gospodnetic <otis_at_my-deja.com> wrote:
>
> >Hello,
> >
> >This seems like it is a FAQ, but I can't find any answers applicable
 to
> >my situation...again :(
> >
> >Platform: Oracle 8i on Linux, JDBC.
> >
> >How does one go about getting X rows from a database (Oracle 8i) at a
> >time without using stored procedures and CallableStatements?
> >
> >I know I could get all the rows once, store the ResultSet and then
 get
> >X elements from it at a time, but I don't want to store ResultSets (I
> >think they would use a ton of memory in my app)
> >
> >I read some docs over on technet.oracle.com that mention ROWID, but
> >their examples show only queries with '...WHERE ROWID >
 somethinghere'
> >But what I really need is something like '...WHERE ROWID > X AND
 ROWID
> >< X+10'
> >
> >(where X is a number)
> >
> >ROWIDs in my database are not stored as numbers so I can't do
 something
> >like WHERE ROWID > 0 AND ROWID < 11. They seem to be stored as some
> >kind of hex(?) value (i.e. alphanumeric characters) which means I
 can't
> >use < and > operators...unless I convert those ROWID values to
> >integers, but I'm afraid that such a conversion would become very
> >expensive as the number of rows increases.
> >
> >Any help would be appreciated.
> >
> >Thank you,
> >
> >Otis
> >
> >
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue Apr 11 2000 - 00:00:00 CDT

Original text of this message

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