FAQ

On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito wrote:

when the table does not exist the prepare fails. How do ignore the error
thrown by the prepare() and catch it later in the program?


my $dbh = DBI->connect("dbi:ODBC:mysql"
,$login
,$passwd
,{ RaiseError => 0 }
);
...
$sth = $dbh->prepare("SELECT COUNT(*) FROM mytable"); # don't catch
$retCode = $sth->execute();
if ($dbh->err) {
print "Table $table -- DOES NOT EXIST\n";
}
....


See if this helps:


use strict;
use warnings;
use 5.010;


eval {
die "***prepare error***";
};

say 'executing other code here';

if ($@) {
say "There was an error inside that eval block above: $@";
}


--output:--
executing other code here
There was an error inside that eval block above: ***prepare error*** at
2perl.pl line 7.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 12 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedFeb 1, '10 at 7:11p
activeFeb 11, '10 at 1:21a
posts12
users5
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase