in reply to trapping database errors

Hello try do something like this to catch your errors
$sth->execute($sqla) or failover($sth->errstr); sub failover() { my $error = shift; $dbh->rollback # If needed; $dbh->disconnect; $mailbody .= "Cannot insert into $database : $error\n"; }
Hope this helps