Re: Help: error not clearing from one call to the next?
- From: Tim.Bunce@xxxxxxxxx (Tim)
- Date: Sun, 24 Apr 2005 12:49:41 -0700
That's odd. You've not stated the DBI or DBD::Oracle versions.
Try using trace (level 4) with a recent version of the DBI
to see what the DBI thinks is happening to the error status.
Tim.
On Thu, Apr 21, 2005 at 09:03:54AM -0700, Joel Stevenson wrote:
> 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
.
- References:
- Help: error not clearing from one call to the next?
- From: Joel Stevenson
- Help: error not clearing from one call to the next?
- Prev by Date: RE: Problems building DBI on Windows
- Next by Date: UTF8 in CSV (was Re: select through DBD::CSV)
- Previous by thread: Help: error not clearing from one call to the next?
- Next by thread: Re: Help: error not clearing from one call to the next?
- Index(es):
Relevant Pages
|