Here's how you would grab the next set of values:
select id, field1, fieldn
from table
where id > cur_value
order by id
fetch first 30 rows only

You would put a number in for cur_value like 30 to get the second set of 30 
records.  If you don't want to run that query each time, just query the 
whole table and put the primary keys into a List object in the user's 
session.  When the user wants the next set of values you query the table 
using an appropriate subset of the primary keys you stored in the session.

These are your 2 best bets.
Dave

>Hi Dave,
>this querry only works for first 30 fields, but what
>if i want to get data from 31 to 60, then either i
>have to have the key for 31 record, or else i will
>have to run the querry twice, first to get the first
>30 and then the next 30 after setting the key..
>i have nottired getting the next 30 records, but this
>querry work on as400 i have tried it before
>Ashish
>--- David Graham <[EMAIL PROTECTED]> wrote:
> > The databases all have their own version of this
> > feature :-( so in SQL
> > Server it's:
> >
> > select top 10 from table
> >
> > which makes the most sense to me.  But, in DB2 you
> > use a "fetch first"
> > clause like this:
> >
> > select * from table
> > fetch first 30 rows only
> >
> > Here's where I found the info
> >
>http://nscpcw.physics.upenn.edu/db2_docs/db2s0/fet1st.htm#HDRFET1ST
> >
> > I tried it out on a db2 7.2 database on win2k so
> > hopefully it works on
> > AS400.
> >
> > Dave
> >
> > >From: Ashish Kulkarni <[EMAIL PROTECTED]>
> > >Reply-To: "Struts Users Mailing List"
> > <[EMAIL PROTECTED]>
> > >To: Struts Users Mailing List
> > <[EMAIL PROTECTED]>
> > >Subject: Re: [OT] RE: Struts and Large ResultSet
> > >Date: Mon, 9 Sep 2002 16:02:00 -0700 (PDT)
> > >
> > >Hi,
> > >I am developing an web interface to existing AS400
> > >system, so there is no way i can go to MYSQL or
> > >suggest to change database, i have to live with
> > AS400
> > >and DB2 and try to find a way out
> > >thanx for suggestion
> > >
> > >--- "Peter A. J. Pilgrim"
> > ><[EMAIL PROTECTED]> wrote:
> > > > Ashish Kulkarni wrote:
> > > > > Hi,
> > > > > But is there a way to write some thing, which
> > is
> > > > > database independent, so u can change the
> > database
> > > > > without any code modification,
> > > > > what i am trying it using CachedRowSet, i load
> > the
> > > > > resultset into a cachedrowset and then display
> > it
> > > > page
> > > > > by page,
> > > > > now only think i have to figure is, how can i
> > load
> > > > > only few records in this rowset, like if i
> > have 1
> > > > > million records, just load say 1000 records,
> > > > iterate
> > > > > through them, if u reach end of cache load
> > another
> > > > > 1000, and so,
> > > > > since a user will never go through a process
> > of
> > > > seeing
> > > > > million records at a time, may be 1000 the
> > max...
> > > > > most user will use some thing like "Go To" to
> > > > point at
> > > > > a specific record in database,
> > > > > I hope this thing works out well
> > > > > Ashish
> > > >
> > > >
> > > > Then you need something like MYSQL which has
> > special
> > > > reserved word to help you limit the size of the
> > > > results.
> > > >
> > > > SELECT LAST_NAME, FIRST_NAME, DEPT FROM
> > > > COMPANY_EMPLOYEES
> > > >     ORDER BY LAST_NAME
> > > >     GROUP BY DEPT
> > > >     LIMIT <offset>, <number-of-rows>
> > > >
> > > > The "LIMIT" word get you a finite rowset
> > limitation
> > > > efficiently on the Database server side. Without
> > > > this
> > > > you may have to read the entire data set out of
> > the
> > > > database. Say you only interested in rows 30 to
> > 40
> > > > then you discard 30 rows already as in normal
> > JDBC
> > > > programming and then kill off the query and
> > result
> > > > after reading row 439.  Suppose the database
> > table
> > > > has 10000 rows, then the database server may in
> > > > efficient
> > > > allocate the time and memory for 1000 rows to
> > read
> > > > by the client. But you stopped on row 40, what
> > > > a waste with 960 unused records!
> > > >
> > > > So in a nutshell go with MYSQL
> > > >
> > > > SELECT CASH_IN, CASH_OUT, INVOICE, CUSTOMER
> > > >   FROM BOOK_BALANCE
> > > >         LIMIT 30, 10
> > > >
> > > > a la google.com
> > > >
> > > > Or I think Oracle my have ROWINDEX attribute.
> > > >
> > > > ROWINDEX >= 30 and ROWINDEX < 40.
> > > >
> > > > Sybase and Postgres I dunno.
> > > >
> > > > --
> > > > Peter Pilgrim         +-----\ +-++----++----+
> > > > Java Technologist     |     | | ||    ||    |
> > 'n'
> > > > Shine
> > > >                        |  O  | | ||  --+| ---+
> > > >          /\            | ._  / | | \  \ |    |
> > > >         /  \           | | \ \ | |+--  || ---+ A
> > new
> > > > day
> > > >        /_  _\  "Up"    | | | | | ||    ||    |
> > is
> > > > coming
> > > >          ||            +-+ +-+ +-++----++----+
> > > > <home page="http://www.xenonsoft.demon.co.uk/";
> > />
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > >
> > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > > > <mailto:[EMAIL PROTECTED]>
> > > >
> > >
> > >
> > >=====
> > >A$HI$H
> > >
> > >__________________________________________________
> > >Do You Yahoo!?
> > >Yahoo! Finance - Get real-time stock quotes
> > >http://finance.yahoo.com
> > >
> > >--
> > >To unsubscribe, e-mail:
> > ><mailto:[EMAIL PROTECTED]>
> > >For additional commands, e-mail:
> > ><mailto:[EMAIL PROTECTED]>
> >
> >
> >
> >
> >
>_________________________________________________________________
> > Join the world�s largest e-mail service with MSN
> > Hotmail.
> > http://www.hotmail.com
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
>
>
>=====
>A$HI$H
>
>__________________________________________________
>Yahoo! - We Remember
>9-11: A tribute to the more than 3,000 lives lost
>http://dir.remember.yahoo.com/tribute
>
>--
>To unsubscribe, e-mail:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to