Subject: | BUG with statement attribute not returned from $dbh do() command |
Date: | Thu, 2 Dec 2010 15:48:17 -0500 |
To: | <bug-DBD-ODBC [...] rt.cpan.org> |
From: | "John Corcoran" <john_corcoran [...] trepp.com> |
Hi,
I found the bug using the following modules DBD::ODBC -- 1.23
DBI -- 1.609
DBD::Sybase -- 1.08
Perl Version: v5.8.8
OS: Linux dev6 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686
i686 i386 GNU/Linux
Basically, I'm writing an error handle for DBI to trap the error message
and the actual SQL statement. I'm currently connecting to MS SQL 2005
using both ODBC (EasySoft) and DBD Sybase (freetds).
The error only happens with DBD::ODBC. The error happens when you write
an incorrect SQL statement using the dbh->do command. In ODBC, I'm
unable to return the SQL Statement using the do command, it only works
with a prepare statement. Its like the SQL Statements been replaced.
Test Script below:
use strict;
use Carp qw(croak cluck);
use DBI;
my $dbh = DBI->
connect("dbi:ODBC:DSN=TEST;UID=sampleuser;PWD=sampleuser;Trusted_Connect
ion=No;APP=$0;");
#my $dbh = DBI->connect("DBI:Sybase:TEST","sampleuser","sampleuser") ||
die "DBI connect failed: $DBI::errstr\n";
print "Testing the following Driver: $dbh->{Driver}->{Name} \n";
$dbh->{AutoCommit} = 1;
$dbh->{RaiseError} = 0;
$dbh->{PrintError} = 0;
$dbh->{ShowErrorStatement} = 0;
$dbh->{HandleError} = \&_err_handler;
$dbh->do("select top 10 * from testTable");
sub _err_handler {
my ($error, $h) = @_;
print "errorMessage: $error \nerrorSql: $h->{Statement}\n" ;
return 0;
}
ODBC Result:
Testing the following Driver: ODBC
errorMessage: DBD::ODBC::db do failed: Invalid object name ' testTable
'. (SQL-42S02)
errorSql:
Expected Result: (What I get back from using DBD Sybase)
Testing the following Driver: ODBC
errorMessage: DBD::ODBC::db do failed: Invalid object name ' testTable
'. (SQL-42S02)
errorSql: select top 10 * from testTable
Thanks
John Corcoran