You are not suppost to use 'or DbError' when fetching, since that will error
out if nothing is fetched, rather just check the return type. Remember that
no data to fetch is not an error, but the fetch method rather returns undef,
just as it does when you fetch some rows and there is nothing else to fetch.
You might want to use it in a conditional statement.
Ilya
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, September 22, 2001 7:38 PM
> To: [EMAIL PROTECTED]
> Subject: Avoid Error if no results
>
>
> Hi All,
>
> this one seems to puzzle me on how to avoid an unnecessary db
> error. I need to
> run a tally count on a couple tables, and if there isn't any data
> in the table
> it displays the dbError, altho there isn't technical any syntax
> error in the
> query other then no return or results.
>
> my $active = 0;
> my $expire = 0;
>
> $sqlquery = qq|SELECT COUNT(m.memid) FROM members m,payhistory p
> WHERE p.active = 'Y' AND p.memid = m.memid|;
> $active = $dbh->selectrow_array($sqlquery) or dbError();
>
> $sqlquery = qq|SELECT COUNT(*) FROM expired WHERE expdate < CURDATE()|;
> $expire = $dbh->selectrow_array($sqlquery) or dbError();
>
> Is this way to avoid the dbError() if the query returns no
> results(which would
> indicate a '0' tally.
>
> thx's
>
> Mike(mickalo)Blezien
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Thunder Rain Internet Publishing
> Providing Internet Solutions that work!
> http://www.thunder-rain.com
> Tel: 1(225)686-2002
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=