|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: DBCOUNT
Date: Nov 27 1998 6:09PM
Dave Waller writes:
> Is there another way to count the rows before you step through them?
>
No.
You can do
select count(*) from foo where ...
select * from foo where ...
but there's no guarantee that the number of rows will be the same
between the first and second selects (there could be an
insert/delete/update operation that went through between the two).
Please read the docs on DBCOUNT in Sybase's OpenCLient DB-Library
manual (available on http://sybooks.sybase.com) for details.
In short - you should write your code to be able to handle any number
of rows because you can't know how many rows you'll get
Michael
>
> Michael Peppler wrote:
>
> > Dave Waller writes:
> > > I must be using this wrong because I get -1 for the value.
> > >
> > > So.. How do you really use DBCOUNT
> >
> > [ I think I'm going to write an autoresponder that replies to DBCOUNT
> > queries automatically... ]
> >
> > DBCOUNT() returns the number of rows affected for update/insert/delete
> > statements.
> >
> > For select statements all the rows need to be processed (via
> > dbnextrow) before DBCOUNT() can return the correct value. This is
> > normal and is due to the way RDBMS engines handle datasets internally
> > (ie the information is not available) This BTW is not a Sybase
> > limitation, Oracle works the same way.
> >
> > Michael
> > --
> > Michael Peppler -||- Data Migrations Inc.
> > mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
> > Int. Sybase User Group -||- http://www.isug.com
> > Sybase on Linux mailing list: ase-linux-list@isug.com
>
>
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|