Here is another bug in DBD::ODBC 0.45_4. When I try to insert the legal string "" (or
undef) into table1, I get the error:
DBD::ODBC::st bind_param failed: [Microsoft][ODBC SQL Server Driver]
Invalid precision value (SQL-HY104)
(DBD: _rebind_ph/SQLBindParameter err=-1) at dbtest4.pl line 12.
Version 0.43 worked correctly. (I think the DATETIME type may have a similar bug.)
use DBI qw(:sql_types);
my $dbh=DBI->connect() or die "Can't connect";
eval {$dbh->do("DROP TABLE table1");};
eval {$dbh->do("CREATE TABLE table1 (str VARCHAR(4000))");};
my $sth = $dbh->prepare ("INSERT INTO table1 (str) VALUES (?)");
my $str = "";
$sth->bind_param (1, $str, SQL_LONGVARCHAR);
$sth->execute();
$dbh->disconnect;
-- Joe
-----Original Message-----
From: Joe Tebelskis
Sent: Wednesday, July 24, 2002 5:56 PM
To: Jeff Urlwin
Cc: [EMAIL PROTECTED]
Subject: bug in DBD::ODBC 0.45_4
Here is a script that exercises another bug in DBD::ODBC 0.45_4. It creates two
tables (table1, table2) and a stored procedure (proc1) that simply inserts a value
into table1. If you execute proc1, and then try to insert a second value into table2,
you get the error:
"DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]
Connection is busy with results for another hstmt (SQL-HY000)
(DBD: st_execute/SQLExecute err=-1) at dbtest2.pl line 27."
On the other hand, if you insert the first value directly (i.e., using $direct=1), it
works fine.
This bug did not exist in version 0.43.
Again, I'm using ActivePerl 5.6.1 and DBI 1.201 under Windows 2000, with SQL Server.
-- Joe
#!perl -w
use strict;
use DBI;
# Connect to the database, and create two tables and a stored procedure:
my $dbh=DBI->connect() or die "Can't connect";
eval {$dbh->do("DROP TABLE table1");};
eval {$dbh->do("CREATE TABLE table1 (i INTEGER)");};
eval {$dbh->do("DROP TABLE table2");};
eval {$dbh->do("CREATE TABLE table2 (i INTEGER)");};
eval {$dbh->do("DROP PROCEDURE proc1");};
eval {$dbh->do("CREATE PROCEDURE proc1 AS ".
"BEGIN INSERT INTO table1 VALUES (1); END");};
# Insert a row into table1, either directly or indirectly:
my $direct = 0;
my $sth1 = $dbh->prepare ($direct
? "INSERT INTO table1 VALUES (1)"
: "EXECUTE proc1");
$sth1->execute();
# Insert a row into table2 (this fails after an indirect insertion):
my $sth2 = $dbh->prepare ("INSERT INTO table2 VALUES (2)");
$sth2->execute();
$dbh->disconnect;