in reply to Re^2: Capturing error thrown by a database
in thread Capturing error thrown by a database
You can set RaiseError =1 and put statements in an eval{} which in this context would be Perl's equivalent of a try/catch. In the case of failure, again, calling the errstr method of the DBI will give you its error.
my $dbh; sub connectsybase { my ($var1, $var2,...) = @_; $dbh = DBI->connect($data_source, $username, $auth, {printError => 1} ); return (DBI->errstr) if (!dbh); # fail return ""; # success, NULL string }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Capturing error thrown by a database
by puneet.keswani (Novice) on Aug 01, 2011 at 12:53 UTC | |
by Marshall (Canon) on Aug 01, 2011 at 13:06 UTC | |
by puneet.keswani (Novice) on Aug 01, 2011 at 13:33 UTC | |
by Marshall (Canon) on Aug 01, 2011 at 14:59 UTC | |
by puneet.keswani (Novice) on Aug 01, 2011 at 18:30 UTC | |
by Marshall (Canon) on Aug 01, 2011 at 15:02 UTC |