Skip to Content.
Sympa Menu

freetds - [freetds] Connecting to Sybase with perl+DBI::ODBC results in an error?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Peter C. Norton" <spacey-freetds.org AT ssr.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Connecting to Sybase with perl+DBI::ODBC results in an error?
  • Date: Tue, 30 Nov 2010 18:50:45 -0500

I've been trying to connect to a Sybase server via perl's DBI::ODBC
module, which calls down through unixODBC (in our case) and then into
freetds. My test code looks like this:

#!/usr/local/bin/perl

use DBI;
# use DBI::ODBC;

my $dbh = DBI->connect('dbi:ODBC:SYBDEV', 'USER', 'PASSWORD',
{AutoCommit=>1});

# my $sth = $dbh->prepare("audit_archive..sp__ls");
# print $sth->execute();
my $sth = $dbh->prepare("select * from audit_archive..sysobjects");
$sth->execute();
my @row;
while(@row = $sth->fetchrow_array) {
print( join(", ", @row), "\n");
}


whatever the AutoCommit attribute is set to, I get this message:

DBI connect('SYBDEV','USER',...) failed: [FreeTDS][SQL Server]Could not
change transaction status (SQL-HY000) [state was HY000 now 01000]

The trace looks like this:

log.c:196:Starting log file for FreeTDS 0.83.dev.hg2git_nortonp.4199
on 2010-11-30 18:46:58 with debug flags 0x4fff.
iconv.c:337:tds_iconv_open(0xb9b1e40, ISO-8859-1)
iconv.c:197:local name for ISO-8859-1 is ISO-8859-1
iconv.c:197:local name for UTF-8 is UTF-8
iconv.c:197:local name for UCS-2LE is UCS-2LE
iconv.c:197:local name for UCS-2BE is UCS-2BE
(etc.)

token.c:2796:tds_process_msg() returning TDS_SUCCEED
token.c:337:looking for login token, got e3(ENVCHANGE)
token.c:122:tds_process_default_tokens() marker is e3(ENVCHANGE)
token.c:2599:changing block size from to 512
token.c:337:looking for login token, got ad(LOGINACK)
token.c:372:server reports TDS version 5.0.0.0
token.c:374:Product name for 0x5000000 is unknown
token.c:337:looking for login token, got e2(CAPABILITY)
token.c:122:tds_process_default_tokens() marker is e2(CAPABILITY)
token.c:337:looking for login token, got fd(DONE)
token.c:122:tds_process_default_tokens() marker is fd(DONE)
token.c:2461:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2477:tds_process_end() state set to TDS_IDLE
token.c:2492: rows_affected = 527
token.c:437:tds_process_login_tokens() returning TDS_SUCCEED
odbc.c:4919:SQLGetFunctions: fFunction is 999
odbc.c:6116:_SQLSetConnectAttr(0xb9b0400, 102, 0x1, 0)
odbc.c:235:change_autocommit: executing WHILE @@TRANCOUNT > 0 COMMIT
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:730:Sending packet
0000 0f 01 00 2a 00 00 00 00-21 1d 00 00 00 00 57 48 |...*.... !.....WH|
0010 49 4c 45 20 40 40 54 52-41 4e 43 4f 55 4e 54 20 |ILE @@TR ANCOUNT |
0020 3e 20 30 20 43 4f 4d 4d-49 54 |> 0 COMM IT|

token.c:539:tds_process_tokens(0xb9b1e40, 0x7fffdfcd8f5c, 0x7fffdfcd8f58,
0x100)
util.c:156:Changed query state from PENDING to READING
net.c:546:Received header
0000 04 01 00 08 00 00 00 00- |........|

net.c:600:Received packet
0000 04 01 00 08 00 00 00 00- |........|

util.c:331:tdserror(0xb9ae0a0, 0xb9b1e40, 20017, 115)
odbc.c:2273:msgno 20017 20003
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
util.c:156:Changed query state from READING to DEAD
token.c:554:processing result tokens. marker is 0()
token.c:122:tds_process_default_tokens() marker is 0()
token.c:125:leaving tds_process_default_tokens() connection dead
util.c:104:logic error: cannot change query state from DEAD to PENDING
error.c:412:odbc_errs_add: "Could not change transaction status"
error.c:517:SQLGetDiagRec(2, 0xb9b0400, 1, 0x7fffdfcd9040, 0x7fffdfcd905c,
0x7fffdfcd8e40, 512, 0x7fffdfcd9058)
error.c:566:SQLGetDiagRec: "[FreeTDS][SQL Server]Unexpected EOF from the
server"
error.c:517:SQLGetDiagRec(2, 0xb9b0400, 2, 0x7fffdfcd9040, 0x7fffdfcd905c,
0x7fffdfcd8e40, 512, 0x7fffdfcd9058)
error.c:566:SQLGetDiagRec: "[FreeTDS][SQL Server]Could not change transaction
status"
error.c:517:SQLGetDiagRec(2, 0xb9b0400, 3, 0x7fffdfcd9040, 0x7fffdfcd905c,
0x7fffdfcd8e40, 512, 0x7fffdfcd9058)


Changing the initial "AutoCommit" attribute's value doesn't seem to
win anything, as it appears to set the autocommit before anything else.

Any ideas, anyone?

-Peter




  • [freetds] Connecting to Sybase with perl+DBI::ODBC results in an error?, Peter C. Norton, 11/30/2010

Archive powered by MHonArc 2.6.24.

Top of Page