Skip to Content.
Sympa Menu

freetds - [freetds] Invalid cursor state (SQL-24000) with SELECT and UPDATE

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: oli.sennhauser AT bluewin.ch
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Invalid cursor state (SQL-24000) with SELECT and UPDATE
  • Date: Thu, 16 Jun 2005 14:13:14 +0200

Hello

I received the following error in one of my perl scripts:
DBD::ODBC::st execute failed: [unixODBC][FreeTDS][SQL Server]Invalid cursor
state (SQL-24000)(DBD: st_execute/SQLExecute err=-1) at freetds_bug.pl line
26.
The concern statement works isolated but not together with the second (see
example).
After playing around I found a workaround but I think it is a bug probably
in freeTDS.
Here the infos for reproducing the bug:
Connection from a Sun (Solaris 9) machine to an MS-SQL Server 2000 DB using
Perl 5.8, unixODBC 2.2.11 and freeTDS 0.63. All that runs in 64 bit mode.
I found 2 issues which could be similar to that problem:
1.) little endian big endian conversion
2.) problems with freetds and 2 statements (insert and select) in 0.62.2

I am not a developper so I am not able to fix but I can help to isolate the
bug (test env ist still available and problem can be reproduced at will).
DBI trace is available, freetds trace is available, example follows below.

One thing made me curious. Could that have an influence. In docu, as far
as I understood, it will be done correctly if iconv is missing:

13:08:06.950539 names for UCS-2LE: UCS-2LE
13:08:06.950624 names for UCS-2BE: (null)

use strict;
use DBI;

#DBI->trace(2, "DBI_trace.log");
my $dbh = DBI->connect( 'dbi:ODBC:SVZTDBA01_Instanz01_MDB_LOG', 'MDB_USER',
'MDB_USER'
, {AutoCommit => 0, PrintError => 1}
) or die print("Database connection not possible."
. $DBI::errstr . "\n");

# ---

my $lSqlStatementSelect =
qq{ SELECT test
FROM test
};
my $sthSelect = $dbh->prepare($lSqlStatementSelect);

$sthSelect->execute();
my ($lTest);
$sthSelect->bind_columns(undef, \$lTest);

# ---

my $lSqlStatementUpdate =
qq{ UPDATE test
SET test = ?
};
my $sthUpdate = $dbh->prepare($lSqlStatementUpdate);

# ---

while ( $sthSelect->fetch ) {
$sthUpdate->execute('Quatsch');
print("Rows updated: " . $sthUpdate->rows . "\n");
}

$dbh->commit();
$sthSelect->finish();
$sthUpdate->finish();
$dbh->disconnect;
exit(0);

# 1.) UPDATE first

# DBD::ODBC::st execute failed: [unixODBC][FreeTDS][SQL Server]Invalid cursor
state (SQL-24000)(DBD: st_execute/SQLExecute err=-1) at freetds_bug.pl line
26.

# 2.) SELECT first

# DBD::ODBC::db prepare failed: (DBD: st_prepare/SQLPrepare err=-1) at
freetds_bug.pl
line 27.
# Can't call method "execute" on an undefined value at freetds_bug.pl line
32.




  • [freetds] Invalid cursor state (SQL-24000) with SELECT and UPDATE, oli . sennhauser, 06/16/2005

Archive powered by MHonArc 2.6.24.

Top of Page