Oops, the SUPER::execute() and error check should happen before the reconstruction:

package MyDbi;
use base 'DBI';

package MyDbi::db;
use base 'DBI::db';

sub prepare {
   my($self,@connect_args) = @_;
   return bless $self->SUPER::prepare(@connect_args), 'MyDbi::st';
}

package MyDbi::st;
use base 'DBI::st';

sub execute {
   my($sth,@binds)[EMAIL PROTECTED];
   my $rv;
   eval { $rv = $sth->SUPER::execute(@binds) };
   return $rv unless $@;
   my $stmt = $sth->{Statement};
   for my $b(@binds) {
       $b = qq{'$b'} if defined $b and !DBI::looks_like_number($b);
       $b = q{NULL} unless defined $b;
       $stmt =~ s/\?/$b/;
   }
   die sprintf "Execution Error: %sReconstructed SQL = %s\n"
             , $sth->errstr, $stmt;
}
1;
__END__

Reply via email to