Hallo all,
while making some tests with DBI, DBD::ODBC, freetds
and MS SQL 2000, I had the following problem.
When I start a little program with the following code
snippet, I get an unexplainable error:
---------------------%<--------------------------------------
print "Before connect\n";
$dbh = DBI->connect($DSN, $DBUSER, $DBPASSWD,
{ RaiseError => 1, AutoCommit => 0}) ||
die "Error while connecting to database: $DBI::errstr";
print "After connect\n";
print "Before disconnect\n";
$dbh->disconnect();
print "After disconnect\n";
---------------------%<--------------------------------------
Output:
Before connect
After connect
Before disconnect
DBD::ODBC::db disconnect failed: [unixODBC] Msg 3903, Level 16, State 1,
Server GUGA, Line 1
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
(SQL-HY000)(DBD: db_rollback/SQLTransact err=-1) at ./odbctest.pl line 19.
DBD::ODBC::db disconnect failed: [unixODBC] Msg 3903, Level 16, State 1,
Server GUGA, Line 1
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
(SQL-HY000)(DBD: db_rollback/SQLTransact err=-1) at ./odbctest.pl line 19.
After that I thought: Ok ok...if you want a transaction begin you get one
and changed the
snippet to the following:
---------------------%<--------------------------------------
print "Before connect\n";
$dbh = DBI->connect($DSN, $DBUSER, $DBPASSWD,
{ RaiseError => 1, AutoCommit => 0}) ||
die "Error while connecting to database: $DBI::errstr";
print "After connect\n";
print "Before BEGIN WORK\n";
$rv = $dbh->begin_work;
print "After BEGIN WORK\n";
print "Before disconnect\n";
$dbh->disconnect();
print "After disconnect\n";
---------------------%<--------------------------------------
Now the output to that:
Before connect
After connect
Before BEGIN WORK
DBD::ODBC::db begin_work failed: Already in a transaction at ./odbctest.pl
line 20.
DBD::ODBC::db begin_work failed: Already in a transaction at ./odbctest.pl
line 20.
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
Now, am I crazy? Have I missed something. Perhaps the specialists out there
can help
me.
Thank you.
Andreas Mock