The DBI book (and presumably the fine DBI manual) suggest that the package vars are very short lived. They're associated with the last used handle, and, presumably, wear red shirts on away missions.
What happens if you use $dbh->err() and $dbh->errstr() instead?
The package variables ($DBI::err and $DBI::errstr) are very shortlived because they are changed everytime an access is made to the DBI (well nearly everytime).
Thus if you have two statements then this
$sth1->execute;
$sth2->execute;
print "Statement 1 failed" if $DBI::err;
is wrong, as $DBI::err contains the error from $sth2.
The DBI book (and the DBI pod) therefore recommends that you use $sth1->err and $sth2->err instead if possible. (They are marignally faster to access as well).