in reply to Re: DBI returning error on selectrow_hashref
in thread DBI returning error on selectrow_hashref

I think your first comment is the culperate. You should only get this error if your $dbh variable is not defined in-line within the application.

If the handle is disconnected, the variable should still be defined. Although will recieve another DBI specific error such as "DBI: Cannot selectrow_hashref from a disconnected database handle" (I really don't know the specific error off hand), you should not expect to see the Perl error.

However, for future reference, and a little off-topic, if you think there might be a chance you are running into an area where your database handle might be disconnected, you can always test against the boolean handle attribute 'Active' and reconnect. For example:
unless ( $dbh->{'Active'} ) { # Some re-connection magic here }
Good Luck!!

---hA||ta----
print map{$_.' '}grep{/\w+/}@{[reverse(qw{Perl Code})]} or die while ( 'trying' );

Replies are listed 'Best First'.
Re^3: DBI returning error on selectrow_hashref
by jZed (Prior) on Nov 29, 2005 at 05:51 UTC
    Your example is good for some uses, but won't prevent the kind of error the OP shows, in fact it will generate a second error of the same kind. A disconnected $dbh is still a $dbh object, his error showed there was no $dbh so doing $dbh->{Active} would generate the same error.