On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
<tony1234567...@yahoo.co.uk>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.

Reply via email to