I may being really daft here but I can't see why changing
ShowErrorStatement should change what happens here (unless
it is consuming errors before the error handler is called).

bash-2.05$ perl -MDBI -e 'print "$DBI::VERSION\n";'
1.48
bash-2.05$ perl --version
This is perl, v5.8.7 built for i686-linux

Driver is MyODBC 3.51.12 but it reports
bash-2.05$ perl -M'DBD::mysql' -e 'print "$DBD::mysql::VERSION\n";'
3.0002

use strict;
use warnings;
use DBI;
use Carp;

my $dbh = DBI->connect("dbi:ODBC:xxx", "yyy", "zzz",
                {RaiseError => 1, PrintError => 1, ShowErrorStatement => 0,
                HandleError => \&error_trap});
my $sth = $dbh->prepare("sselect * from bench_char");
$sth->execute;
sub error_trap
{
        my ($msg, $h, $ret) = @_;

        print "Type=", $h->{Type}, "\n",
                "SQL=", $h->{Statement}, "\n",
                "Error=", $h->errstr, "\n";
        confess("confess");
        return 1;
}

shows:

bash-2.05$ perl x.pl
Type=st
SQL=sselect * from bench_char
Error=[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.15-log]You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near
'sselect * from bench_char' at line 1 
(SQL-23000)(DBD: st_execute/SQLExecute err=-1)
confess at x.pl line 21
        main::error_trap('DBD::ODBC::st execute failed: 
        [unixODBC][MySQL][ODBC 3.51 Dri...', 
        'DBI::st=HASH(0x8248b04)', 'undef') called at x.pl line 12

which is what I'd expect BUT simply changing ShowErrorStatement => 1 produces:

bash-2.05$ perl x.pl 
Describe failed during DBI::st=HASH(0x8248af8)->FETCH(ParamValues,0) 
at x.pl line 12.
Type=st
SQL=sselect * from bench_char
Error=[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.15-log]
Invalid cursor state (SQL-24000)(DBD: dbd_describe/SQLNumResultCols err=-1)
confess at x.pl line 21
        main::error_trap('DBD::ODBC::st execute failed: 
        [unixODBC][MySQL][ODBC 3.51 Dri...', 'DBI::st=HASH(0x8248b04)', 
'undef') called at x.pl line 12

It would appear setting ShowErrorStatement:

1. causes the code to run further before stopping
2. loses an error

Any ideas?

Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development

Reply via email to