We use a transaction to prevent this.  In JDBC it's very simple, just turn
off auto-commit.
    (*Chris*)

----- Original Message -----
From: Bob Withers <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 04, 1999 4:33 AM
Subject: Re: Number of rows a query retrieved?


> Chris,
>
> It is also important to consider that it is possible for the number of
rows
> that will be returned to change between the two queries if other sessions
> are updating the data base.  It would be entirely possible for the select
> count(*) to return a count of 1000 and have the second query return zero
> rows.
>
> Regards,
> Bob
>
> ------------------------------------------------------------------------
> -------------------
> Bob Withers                                    Two things are infinite:
the
> universe and
> [EMAIL PROTECTED]                            human stupidity, and I'm not
sure
> about
> http://www.pobox.com/~bwit       the universe.     - Albert Einstein
> ------------------------------------------------------------------------
> -------------------
> ----- BEGIN GEEK CODE BLOCK -----
> Version 3.1 http://www.geekcode.com
> GCS d- s: a+ C++ UO++ P L++ E--- W++ N++ o-- w++
> O M V- PS PE Y+ PGP t+ 5 X++ r* tv+ b++ DI++ D--- G
> e++ h--- r+++ y+++
> ----- END GEEK CODE BLOCK -----
>
>
> On Tuesday, June 29, 1999 11:35 AM, Chris Pratt
> [SMTP:[EMAIL PROTECTED]] wrote:
> > >From what I understand, the first query is only slightly faster than
the
> > second (since it doesn't have to build a full ResultSet), but Oracle has
> > pretty aggressive caching, so the second query (having the same where
> > clause) should run out of the cached data from the first call and be
very
> > quick.  Overall, it's slower, but nowhere near twice as slow.
> >     (*Chris*)
> >
> > ----- Original Message -----
> > From: Xizhen Wang <[EMAIL PROTECTED]>
> > To: Chris Pratt <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Monday, June 28, 1999 6:34 PM
> > Subject: Re: Number of rows a query retrieved?
> >
> >
> > >
> > >
> > > Chris Pratt wrote:
> > > >
> > > > Oh, I should have mentioned, that using simple SQL, you can also use
> the
> > > > COUNT operator to test how many rows will be returned.  Like this:
> > > >
> > > > select count(*) from employees where city='San Jose'
> > > > select * from employees where city='San Jose'
> > >
> > > Thank you!
> > > So another question is: is the first query as time-comsuming as the
2nd
> > > one?
> > > if this is true, i'd rather do only one query.
> > >
> > > thanks!
> > >
> > > xizhen
> > >
> > >
> > > >
> > > > The first query will return a single row in its ResultSet that
> consists
> > of
> > > > one Numeric value equal to the number of rows that the second query
> will
> > > > return (Assuming that no updates happen between the two
invocations).
> > > >     (*Chris*)
> > > >
> > > > ----- Original Message -----
> > > > From: Chris Pratt <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > > > Sent: Monday, June 28, 1999 2:42 PM
> > > > Subject: Re: Number of rows a query retrieved?
> > > >
> > > > > In standard JDBC, there is no way to tell this before you have
read
> > the
> > > > last
> > > > > row.  There are packages, like Village or Town, that do have this
> > > > > capability, but I have not tested them.  You could also use a true
> > OODB,
> > > > > like CloudScape, which has this type of capability.
> > > > >     (*Chris*)
> > > > >
> > > > > ----- Original Message -----
> > > > > From: Xizhen Wang <[EMAIL PROTECTED]>
> > > > > To: <[EMAIL PROTECTED]>
> > > > > Sent: Monday, June 28, 1999 12:44 AM
> > > > > Subject: Number of rows a query retrieved?
> > > > >
> > > > >
> > > > > > Hi! In jdbc, how to know the number of rows a query retrieved?
Is
> > there
> > > > > > a good way other than using ResultSet.next()?
> > > > > >
> > > > > > Thanks!
> > > > > >
> > > > > >
> > > > >
> > > >
> >
>
___________________________________________________________________________
> > > > > > 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
> > > > > >
> > > > >
> > >
> >
> >
>
___________________________________________________________________________
> > 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
>
>
___________________________________________________________________________
> 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
>

___________________________________________________________________________
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