develooper Front page | perl.dbi.users | Postings from July 2006

[DBD-ADO] bind_param broken in version 2.95?

Thread Next
From:
jderrick
Date:
July 22, 2006 08:21
Subject:
[DBD-ADO] bind_param broken in version 2.95?
Message ID:
00a401c6ada2$7b7c51d0$fcc44b0c@mako
Hi Everybody,

DBD-ADO version 2.95 appears to have a problem with the bind_param command when using the SQL type constants.  The problem does not occur with version 2.94.  See the dbi-users posting "Possible bug in DBD-ADO 2.94 bind_param" from September 24, 2005 for more info.  See below for example code, error message received, and the source line in DBD-ADO that is causing the error.  MS Access is the database being used by the example code. 

Thanks and regards,
John


Error:
Can't use string ("3") as a HASH ref while "strict refs" in use at C:/Perl/site/lib/DBD/ADO.pm line 1022.

ADO.pm Source line 1022:
$i->{Size}  = defined $attr->{ado_size} ? $attr->{ado_size} : length $value;


Example code:

use DBI qw(:sql_types);

my $provider = "Microsoft.Jet.OLEDB.4.0";
my $datasource = "db1.mdb";

my $createSQL = <<END;
CREATE TABLE test1 (
    col1  COUNTER PRIMARY KEY,
    col2  DECIMAL(9,2),
    col3  VARCHAR(20)
)
END

my $insertSQL = "INSERT INTO test1 (col2, col3) VALUES (?, ?)";

my $dbh = DBI->connect("dbi:ADO:Provider=$provider;Data Source=$datasource", "", "", {PrintError => 1});
die "could not connect to db $datasource" unless $dbh;

$dbh->do($createSQL) or print "error on create table";
my $sth = $dbh->prepare($insertSQL) or die "could not prepare SQL insert";

$sth->bind_param(1, 383874379.99, SQL_DECIMAL);
$sth->bind_param(2, "this is a string", SQL_VARCHAR);
$sth->execute();

$dbh->disconnect();
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About