[egenix-users] 'Invalid cursor state' when using placeholders?

M.-A. Lemburg mal at egenix.com
Mon Jan 12 14:58:28 CET 2004


Fabricio Chalub wrote:
> Hello,
> 
> Does anyone observe this behavior on mxODBC?
> 
> I get a 
> 
> mxODBC.InternalError: ('24000', 0, '[FreeTDS][SQL Server]Invalid cursor state', 2363)
> 
> when running the simple example below.  The values are
> actually inserted on the database, but mxODBC dies with
> that error.  I'm using FreeTDS 0.62rc3 (current), iODBC
> (3.51.1), unixODBC (2.2.7) and mxODBC (2.0.6) connecting
> to SQL Server 2000.  

This looks like a bug in FreeTDS: mxODBC is trying to read the number
of rows in the result set. Since there is no result set, the ODBC
should return 0 (like all other drivers do). Instead, FreeTDS reports
an error.

> If I do the placeholder substitution directly, ie, do 
> something like 
> 
> INSERT INTO some_table (c1,c2,c3,c4,c5,c6) VALUES ('C',1,'a','b','c','d')
> 
> it works nicely.  Any ideas to make this work with
> the placeholders cleanly?

Not cleanly, but in this case, you can safely ignore the false error
from FreeTDS.

I'd suggest sending them a bug report.

> ---
> 
> import mx.ODBC.iODBC
> cto = mx.ODBC.iODBC.DriverConnect ("DSN=sqlserver;UID=YYY;PWD=XXX")
> areaI = "INSERT INTO some_table (c1,c2,c3,c4,c5,c6) VALUES (?,?,?,?,?,?)"
> c2 = cto.cursor()
> c2.execute(areaI, ('C', 1, 'T1', 'T2', 'T3', 'T4'))
> 
> Thanks,
> Fabricio
> 
> 
> _______________________________________________________________________
> eGenix.com User Mailing List                     http://www.egenix.com/
> http://lists.egenix.com/mailman/listinfo/egenix-users

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 06 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the egenix-users mailing list