Alternatively to using a Vector - they're quite processor-intensive to construct
and memory-intensive to keep hanging around in the session, you can use the
LIMIT (or equivalent) keyword in your query to only retrieve the first 50, then
the next 50 etc etc. You may well want to make a preliminary query to find out
how many records the search has returned, but the overall speed should be much
better.

e.g. with MySQL
in the first instance:
    SELECT count(*) FROM tablename WHERE field1=val1 AND field2 = val2
    SELECT * FROM tablename WHERE field1=val1 AND field2 = val2 LIMIT 50

2nd page:
    SELECT * FROM tablename WHERE field1=val1 AND field2 = val2 LIMIT 50,50

hope this is helpful

simon

"Ozkan, Ejber" wrote:

> hmmm
> one way I guess to process this form would be to have a loop that
> grows with each not null parameter from the post.
> i.e pseudo code..
>
> query = " select clause from clause where "
> while loop
> query.append(" field1 = "+ parameter[loop]);
> if anymore params query.append(" and");
> else end of query
> end loop
>
> then push this string into the connection to the DB
>
> To page the information I usesully use a Vector to store all of the data and
> then you can
> simply loop through 50 elements (rows) at time per page display ,making sure
> to keep track of the last page number and row, at the end of each page just
> have a submit button that contains the current page number for the
> next page.
>
> Kind Regards
>
> Ejber Ozkan                         Internet Applications Developer
> Ezz                                     Colt Internet
>                                            Pager 0941148608
> [EMAIL PROTECTED]
>
> > -----Original Message-----
> > From: Jeetandra Mahtani [SMTP:[EMAIL PROTECTED]]
> > Sent: 18 May 1999 20:57
> > To:   [EMAIL PROTECTED]
> > Subject:      complicated sql...need some help...
> >
> > Hello,
> > I am working on an inquiry form and I am kind of stuck in thinking of
> > an optimum way to write the sql to do the inquiry. The form consists
> > of 8 fields and the user needs to fill out atleast one field. A
> > servlet will take the values entered(atleast one) by the user and
> > search a table based on the values entered by the user.
> > Now, there can be so many combinations since the user may enter one
> > field or two ..etc.Any suggestions on how I could write the sql?
> > Also, the sql may return a thousand records..how do I display about 50
> > records per page. If the user clicks on a next button, the next 50
> > records are displayed. Any idea on how I could split the retrieved
> > records into pages.Thanks,JGM
> > _____________________________________________________________

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to