Thank you for your reply Ian. The $dbh->do() approach suffers from the same problem, do() doesn't return. The program behaves in a classic "throwing an exception" mode by not returning an error value and, appears to be, exiting the execution stack abruptly printing the word "Aborted" to stderr.
I appreciate your suggestion for using log4perl but I have thousands of lines of code that have been in service for years. My simplistic example on this posting doesn't reflect the complexity of some of the transactions which I hope not to be rewriting/refactoring anytime soon. Thanks again Ian - all suggestions are appreciated. KFW At 04:46 PM 8/25/2009, Ian Harisay wrote:
I wouldn't even use the eval block. Set PrintError and RaiseError to 0. Try something along these lines.my $rv = $dbh->do(<<" EOS"); UPDATE ????? set $attribute = $value WHERE decimal_latidude = $dLat AND decimal_longitude = $dLon AND image_date = to_date('2008-03-05', 'yyyy-mm-dd') EOS unless($rv){ print("Error in updateFoo() - $dbh->errstr\n"); $dbh->disconnect(); closeFileHandles(); exit(-1); }But personally I use log4perl and would write it like this along with using placeholders.my @blist = ($value, $dLat, $dLon); my $rv = $dbh->do(<<" EOS",{},@blist) || $log->error($dbh->errstr); UPDATE table_name set $attribute = ? WHERE decimal_latidude = ? AND decimal_longitude = ? AND image_date = to_date('2008-03-05', 'yyyy-mm-dd') EOS Hope that helps. -----Original Message----- From: Kevin Webb [mailto:[email protected]] Sent: Tuesday, August 25, 2009 11:54 AM To: [email protected] Subject: Problem catching exceptions Greetings! My eval blocks are not catching exceptions when executed on RH el5 installations. The following code worked as expected on an RH ELsmp machine, but when the code got relocated eval stopped working as expected. The code couldn't be much simpler ... sub updateFoo() { ... eval {my $stmnt = $dbHandle->prepare("UPDATE ????? set $attribute = $value \WHERE decimal_latidude = $dLat \ AND decimal_longitude = $dLon \ AND image_date = to_date('2008-03-05', 'yyyy-mm-dd')"); $stmnt->execute(); }; if ($@) { print("Error in updateFoo() - $...@\n"); $dbHandle->disconnect(); closeFileHandles(); exit(-1); } } This used to work on ELsmp (2.6.9-78.0.17.ELsmp) with DBI-1.50.tar.gz, and DBD-Oracle-1.17.tar.gz using default values for RaiseError and PrintError. I am now on an RH el5 (2.6.18-53.1.14.el5) installation using perl-DBI-1.40-8.x86_64.rpm and perl-DBD-Oracle-1.19-1.el5.x86_64.rpm. I have intentionally misspelled 'decimal_latidude' to trigger a ORA-00904: "DECIMAL_LATIDUDE": invalid identifier (as reported by DBI->trace(4)). I have fiddled with: $dbHandle->{RaiseError} = 1; $dbHandle->{PrintError} = 0; as well as $stmnt->{RaiseError} = 1; and all that happens is a bailout on $stmnt->execute() with the word 'Aborted' dumped to stderr ($stmnt->execute() does not return a value). $dbHandle->do() suffers in a similar fashion. Any ideas? Thank you. KFW
