Help: error not clearing from one call to the next?
- From: joelstevenson@xxxxxxx (Joel Stevenson)
- Date: Thu, 21 Apr 2005 09:03:54 -0700
Hi all,
I'm running into an interesting problem with a database error that occurs on one statement handle and seems to affect another handle despite using eval {...} and RaiseError. Perhaps example code would be describe the situation:
my $attr = {RaiseError => 1};
my $dbh = DBI->connect ('dbi:mysql:','user','pass', $attr);my $topSTH = $dbh->prepare ("SELECT NAME FROM FOO");
$topSTH->execute ();while (my $hashRef = $topSTH->fetchrow_hashref ()) {# do stuff here
eval {
my $inSTH = $dbh->prepare ("SELECT SOMEVALUE FROM MYMAYBETABLE WHERE ID=1");
$inSTH->execute ();
my ($value) = $inSTH->fetchrow_array ();
# do something with value
};
if ($@) {
print STDERR "ERR: $@";
}}
MYMAYBETABLE is a table that may or may not exist and because of that I wrapped the prepare/execute in an eval. When the table does not exist the error is caught and handled as expected (the "ERR: $@" line is printed to STDERR) but for some reason the next iteration of the while loop throws exactly the same error from the $topSTH->fetchrow_hashref call even though it is not touching MYMAYBETABLE at all. So I get "DBD::mysql::st fetchrow_hashref failed: Table 'MYMAYBETABLE' doesn't exist at ..." being thrown from both $inSTH and $topSTH !?
So it seems like the error that occurred in $inSTH is being held onto and affecting other statement handles created from the same database handle.
I've been looking through the list archives but as yet haven't found anything about this. Is this expected behavior? If so, how can I clear the error so that the top while loop can continue on after such an error?
TIA, Joel .
- Follow-Ups:
- Prev by Date: RE: :Oracle install problem On Solaris 8
- Next by Date: Re: inserting data coming from a hash
- Previous by thread: Failed DBD Oracle 1.16 make on Perl 5.8.6, DBI 1.48, Oracle 9.2.0.6, Solaris 8.
- Next by thread: Re: Help: error not clearing from one call to the next?
- Index(es):