On some 64-bit systems, python-sybase versions 0.39+ are throwing the following error for certain queries against a SQL Server:
DatabaseError: Msg 16902, Level 16, State 24, Procedure sp_cursoropen, Line 1
sp_cursoropen: The value of the parameter 'scrollopt' is invalid.
The queries affected seem to be anything that changes data (Insert/Update/Delete) -or- selects from SQL Server system-level objects (server objects, stored procedures, etc). Straight-up SELECT queries from data tables are, for some reason, unaffected and working properly. This problem does not seem to affect 32-bit systems, and does not occur in python-sybase version 0.38.
(Testing system is CentOS 5.6 64-bit with FreeTDS 0.82 and Sybase OCS libraries v15.5esd2)
There is a mailing list post about this from 2009 describing the exact same issue, but there was no substantive conversation or resolution. I can confirm that it is not a FreeTDS issue, as other database interfaces on the same system work properly. See examples below:
-----
python-sybase v0.40pre1
>>> import Sybase
>>> d = Sybase.connect( dsn='XXX', user='XXX', passwd='XXX', database='XXX', auto_commit=0 )
>>> c = d.cursor()
>>> c.execute("select count(*) from INFORMATION_SCHEMA.TABLES")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib64/python2.4/site-packages/Sybase.py", line 741, in execute
self._start()
File "/usr/lib64/python2.4/site-packages/Sybase.py", line 886, in _start
return self._mainloop()
File "/usr/lib64/python2.4/site-packages/Sybase.py", line 900, in _mainloop
self._raise_error(e)
File "/usr/lib64/python2.4/site-packages/Sybase.py", line 945, in _raise_error
raise exc
Sybase.DatabaseError: Msg 16902, Level 16, State 24, Procedure sp_cursoropen, Line 1
sp_cursoropen: The value of the parameter 'scrollopt' is invalid.
-----
Same system, FreeTDS tsql utility:
# tsql -Sxxx -Uxxx -Pxxx
locale is "en_US.UTF-8"
locale charset is "UTF-8"
1> select count(*) from INFORMATION_SCHEMA.TABLES;
2> go
20
(1 row affected)
I attempted to reproduce this on a 64-bit Linux system but couldn't.
I will close this ticket, please re-send another bug reprot if the problem persists.