5 messages in com.mysql.lists.perlRe: Intercepting DBD:ODBC errors
FromSent OnAttachments
zzapper11 Apr 2005 08:56 
Garry Williams11 Apr 2005 09:45 
zzapper11 Apr 2005 10:00 
Garry Williams11 Apr 2005 10:37 
zzapper14 Apr 2005 08:04 
Subject:Re: Intercepting DBD:ODBC errors
From:zzapper (dav@tvis.co.uk)
Date:04/14/2005 08:04:27 AM
List:com.mysql.lists.perl

On Mon, 11 Apr 2005 13:37:46 -0400, wrote:

On Mon, 2005-04-11 at 18:00 +0100, zzapper wrote:

On Mon, 11 Apr 2005 12:45:51 -0400, wrote:

On Mon, 2005-04-11 at 16:57 +0100, zzapper wrote:

[snip]

By default, "DBI->connect" sets "PrintError" "on".

Whoops I also had it specifically switched on, but what's the best policy have it on for testing OR leave it off and always test at the Perl level?

I don't know.

I usually specify RaiseError => 1, PrintError => 0. I also wrap queries that I expect can fail in eval { ... }, if I want to process the failure. Otherwise, the default behavior is fine. (The exception is not caught and results in a message on stderr and non-zero exit() code.)

Gary My experiences You must set raiseerror otherwise hangs or reports no errors

The only way I could intercept the errors was with eval (thanx)

eval {$sel = $db->prepare($sql); $sel->execute}; &fn_error_handler($sql) if $@;

BTW watch out for eval as it changes data scoping!!!

Cheers!!