Skip to Content.
Sympa Menu

freetds - [freetds] Non-expected data received from MSSQL 2005

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Thomas Möller <thomas.moller AT systeam.se>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Non-expected data received from MSSQL 2005
  • Date: Thu, 14 Feb 2008 14:21:54 +0100



Hi all,



I'm new to the usage of the FreeTDS and DBD::Sybase combination.

I am seemingly able to connect to the DB correctly. It may perhaps

be as simple as my MSSQL syntax is failing?



However, when executing the classical test PERL script to fetch

the server version:



--- snip ---



#!/usr/bin/perl



use DBI;



#DBI->trace(3);



my $dbh = DBI->connect("dbi:Sybase:server=192.168.0.1", 'user', 'password',
{PrintError => 0});



die "Unable to connect to server: $DBI::errstr" unless $dbh;



my ($src, $sth);



$sth = $dbh->prepare("SELECT \@\@Servername");



if($sth->execute) {

@dat = $sth-fetchrow;

print "@dat\n";

}



--- snip ---



I get very strange results. The output results in a number, eg:



136916248



and if I use the 'fetchrow' statement in a while loop, the list

of numbers continue endlessly:



136916248

136916248

136916248

136916248

136916248

...



I noticed that the end part of the number changes for each

execution, indicating that it is perhaps time or session number

related?



The versions of each package I'm using are the following:

FreeTDS: v0.64

DBD::Sybase: v1.08

Perl: v5.8.8

MSSQL: 2005 in Win2k3

Distro: Gentoo



/etc/freetds.conf:

[SQLSERVER1]

host = 192.168.0.1

port = 1433

tds version = 8.0



The rest is default





Anyhow, to further help you in helping me I have included a

trace log below:



--- snip ---



DBI 1.601-nothread default trace level set to 0x0/3 (pid 13518) at dbtest
line 5

Note: perl is running without the recommended perl -w option

-> DBI->connect(dbi:Sybase:server=192.168.0.14, user, ****,
HASH(0x8142180))

-> DBI->install_driver(Sybase) for linux perl=5.008008 pid=13518 ruid=0
euid=0

syb_init() -> DBD::Sybase 1.08 initialized

OpenClient version: freetds v0.64 (threadsafe, default tds version=7.0)

install_driver: DBD::Sybase version 1.08 loaded from
/usr/lib/perl5/site_perl/5.8.8/i686-linux/DBD/Sybase.pm

New 'DBI::dr' (for DBD::Sybase::dr, parent='', id=undef)

dbih_setup_handle(DBI::dr=HASH(0x81d547c)=>DBI::dr=HASH(0x81ce680),
DBD::Sybase::dr, 0, Null!)

dbih_make_com(Null!, 0, DBD::Sybase::dr, 84, 0) thr#0

<- install_driver= DBI::dr=HASH(0x81d547c)

!! warn: 0 CLEARED by call to connect method

-> connect for DBD::Sybase::dr (DBI::dr=HASH(0x81d547c)~0x81ce680
'server=192.168.0.14' 'user' **** HASH(0x81e1eec))

New 'DBI::db' (for DBD::Sybase::db, parent=DBI::dr=HASH(0x81ce680),
id=undef)

dbih_setup_handle(DBI::db=HASH(0x82941e0)=>DBI::db=HASH(0x829415c),
DBD::Sybase::db, 8217cc4, Null!)

dbih_make_com(DBI::dr=HASH(0x81ce680), 81cb8b0, DBD::Sybase::db, 2764, 0)
thr#0

syb_db_login() -> using global CS_LOCALE data

syb_db_login() -> checking for chained transactions

syb_db_login() -> ct_option is supported

syb_db_login() -> chained transactions are supported

get_server_version() -> ct_command(select @@version)

get_server_version() -> ct_results(4040)

get_server_version() -> version = Microsoft SQL Server 2005 -
9.00.3042.00 (Intel X86)

Feb 9 2007 22:47:07

Copyright (c) 1988-2005 Microsoft Corporation

Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)



get_server_version() -> version = Unknown

get_server_version() -> ct_results(4046)

<- connect= DBI::db=HASH(0x82941e0) at DBI.pm line 639

-> STORE for DBD::Sybase::db (DBI::db=HASH(0x829415c)~INNER 'PrintError'
0)

STORE DBI::db=HASH(0x829415c) 'PrintError' => 0

<- STORE= 1 at DBI.pm line 691

-> STORE for DBD::Sybase::db (DBI::db=HASH(0x829415c)~INNER 'AutoCommit'
1)

syb_db_commit() -> ct_command(

COMMIT TRAN

)

syb_db_commit() -> ct_send() OK

syb_db_commit() -> ct_results(4048) == 1

syb_db_commit() -> ct_results(4046) == 1

ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2
server=SQLSERVER1 text=The COMMIT TRANSACTION request has no corresponding
BEGIN TRANSACTION.' (err#0)

<- STORE= 1 at DBI.pm line 691

-> STORE for DBD::Sybase::db (DBI::db=HASH(0x829415c)~INNER 'Username'
'user')

STORE DBI::db=HASH(0x829415c) 'Username' => 'smsreader'

ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2
server=SQLSERVER1 text=The COMMIT TRANSACTION request has no corresponding
BEGIN TRANSACTION.' (err#0)

<- STORE= 1 at DBI.pm line 694 via at dbtest line 7

ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2
server=SQLSERVER1 text=The COMMIT TRANSACTION request has no corresponding
BEGIN TRANSACTION.' (err#0)

<> FETCH= 'smsreader' ('Username' from cache) at DBI.pm line 694

-> connected in DBD::_::db for DBD::Sybase::db
(DBI::db=HASH(0x82941e0)~0x829415c 'dbi:Sybase:server=192.168.0.1' 'user'
'password' HASH(0x8142180))

ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2
server=SQLSERVER1 text=The COMMIT TRANSACTION request has no corresponding
BEGIN TRANSACTION.' (err#0)

<- connected= undef at DBI.pm line 700

<- connect= DBI::db=HASH(0x82941e0)

-> STORE for DBD::Sybase::db (DBI::db=HASH(0x829415c)~INNER
'dbi_connect_closure' CODE(0x828c378))

STORE DBI::db=HASH(0x829415c) 'dbi_connect_closure' => CODE(0x828c378)

ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2
server=SQLSERVER1 text=The COMMIT TRANSACTION request has no corresponding
BEGIN TRANSACTION.' (err#0)

<- STORE= 1 at DBI.pm line 709 via at dbtest line 7

!! ERROR: 3902 CLEARED by call to prepare method

-> prepare for DBD::Sybase::db (DBI::db=HASH(0x82941e0)~0x829415c 'SELECT
@@Servername')

New 'DBI::st' (for DBD::Sybase::st, parent=DBI::db=HASH(0x829415c),
id=undef)

dbih_setup_handle(DBI::st=HASH(0x829439c)=>DBI::st=HASH(0x8294174),
DBD::Sybase::st, 8217f28, Null!)

dbih_make_com(DBI::db=HASH(0x829415c), 8294f50, DBD::Sybase::st, 420, 0)
thr#0

syb_st_prepare() -> inUse = 0

syb_st_prepare() -> set inUse

<- prepare= DBI::st=HASH(0x829439c) at dbtest line 13

-> execute for DBD::Sybase::st (DBI::st=HASH(0x829439c)~0x8294174)

cmd_execute() -> ct_command() OK

cmd_execute() -> ct_send() OK

cmd_execute() -> set inUse flag

st_next_result() -> ct_results(4040) == 1

ct_res_info() returns 1 columns

STORE DBI::st=HASH(0x8294174) 'NUM_OF_FIELDS' => 1

describe() -> col 0, type 0, realtype 0

describe() retcode = 1

st_next_result() -> lasterr = 0, lastsev = 0

<- execute= -1 at dbtest line 15

136922012

<> DESTROY(DBI::st=HASH(0x829439c)) ignored for outer handle (inner
DBI::st=HASH(0x8294174) has ref cnt 1)

-> DESTROY for DBD::Sybase::st (DBI::st=HASH(0x8294174)~INNER)

syb_st_finish() -> ct_cancel(CS_CANCEL_ALL)

clear_sth_flags() -> resetting ACTIVE, moreResults, dyn_execed, exec_done

clear_sth_flags() -> reset inUse flag

syb_st_destroy: called on 82a7348...

syb_st_destroy(): freeing imp_sth->statement

syb_st_destroy(): cmd dropped: 1

<- DESTROY= undef

<> DESTROY(DBI::db=HASH(0x82941e0)) ignored for outer handle (inner
DBI::db=HASH(0x829415c) has ref cnt 1)

-> DESTROY for DBD::Sybase::db (DBI::db=HASH(0x829415c)~INNER)

syb_db_disconnect() -> ct_close()

<- DESTROY= undef

-- DBI::END ($@: , $!: )

-> disconnect_all for DBD::Sybase::dr (DBI::dr=HASH(0x81d547c)~0x81ce680)

<- disconnect_all= 1 at DBI.pm line 718 via at dbtest line 0

! -> DESTROY in DBD::_::common for DBD::Sybase::dr
(DBI::dr=HASH(0x81ce680)~INNER)

! <- DESTROY= undef during global destruction

! <> DESTROY for DBI::dr=HASH(0x81d547c) ignored (inner handle gone)



--- snip ---



According to my interpretation of the trace log, most seems to

be just fine...Or? Do I fail to decode returned data or something?



The COMMIT error may be eliminated by issuing 'AutoCommit => 0'

but the error will still remain regarding the returned data.

I've also tried to fetch other types of data only to get the

same results.



Any ideas? Or do I need to switch over to DBD::ODBC or something?



Best regards

/Thomas




  • [freetds] Non-expected data received from MSSQL 2005, Thomas Möller, 02/14/2008

Archive powered by MHonArc 2.6.24.

Top of Page