in reply to DBI, From PHP to Perl

Others have explained about the $sth->rows() call, so I'll just point out that your current method isn't guaranteed to be exact - there's nothing that prevents the number of rows that match the query to change between your select count(*) and your actual select of the rows.

I've found that I've always been able to find a way to only need to know the number of rows after I've fetched them, no matter what language I was using. You might want to re-think your algorithm with that in mind.

Michael