Guay Jean-Sébastien wrote:
Hello Andrew,


Is there a way to find out how many records were returned with a DBI query? There's the obvious counting each record as you fetch it, but I need the count before I start going through them.


I was looking through the DBI documentation (perldoc DBI) not long ago and
this caught my eye... It's in the "Statement Handle Methods" section. Just
proof that sometimes the info is there, but it's hard to find or buried in a
very big man page (which certainly is the case for the DBI man page...).

<-------------------- snip -------------------->
rows

$rv = $sth->rows;

    Returns the number of rows affected by the last row affecting command,
or -1 if the number of rows is not known or not available.

    Generally, you can only rely on a row count after a non-SELECT execute
(for some specific operations like UPDATE and DELETE), or after fetching all
the rows of a SELECT statement.

With the mysql driver, it does return the number of fetched rows before you start iterating through them. It does what I need it to do. Thanks.


--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to