[freetds] Invalid cursor state when executing 2 SELECT statements

Sebastien FLAESCH sf at 4js.com
Mon Dec 17 06:09:12 EST 2007


Dear all,
(hope it helps to send such little test programs in this mailing list).

Attached a little test program executing 2 statements concurrently.

For now with FreeTDS 0.65 I get:

Error -1 at: SQLExecute 2
Diagnostic info:
   SQL State: 24000
   SQL code : 0
   Message  : [FreeTDS][SQL Server]Invalid cursor state

When I run the same program with SQL Native Client, I get following output:

 >> Fetch from 1: [aaa]
 >> Fetch from 2: [aaa]

Note that you must set a statement attribute like:

SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE

or:

SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_LOCK

... to get sp_cursor* driven cursors, as you probably know.

It's certainly a good idea to test all possible statement attributes you can
set with ODBC, and check what SQL Native Client sends to the server...

There are a couple of sp_cursoroption calls you should take care of.

Seb

Sebastien FLAESCH wrote:
> Dear all,
> 
> I just want to:
> 
>     SQLPrepare(stmt1, "SELECT ...");
>     SQLPrepare(stmt2, "SELECT ...");
>     SQLExecute(stmt1);
>     SQLExecute(stmt2);
> 
> But second SQLExecute() returns "Invalid cursor state".
> 
> I must either issue an SQLFetch() or SQLCloseCursor() with the first statement
> to be able to execute the second one.
> 
> Is this a known limitation of the FreeTDS ODBC driver?
> 
> Thanks
> Seb
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: odbctest12.c
Type: text/x-csrc
Size: 7142 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20071217/110a9039/attachment-0001.bin 


More information about the FreeTDS mailing list