[DB-SIG] mx.ODBC.Windows - execute() parameter substitution raises Exception
Krjukov Victor
VKryukov@ufg.com
Wed, 2 Oct 2002 13:47:16 +0400
Greetings, db-sig, I've faced with strange mx.odbc.windows execute()
behaviour.
Can someone please explain me why the following code fails on 4th
execute? May be I'm just missing something very simple...
I'm running
mx.ODBC.Windows 2.0.5
Python 2.2.1c2 (#33, Mar 26 2002, 13:04:18) [MSC 32 bit (Intel)] on
win32
MS SQL server 2000
Windows 2000
=3D=3D=3D=3D> test_sql.py
import mx.ODBC.Windows
DB =3D mx.ODBC.Windows.Connect('db-companies')
C =3D DB.cursor()
sql =3D """select newsid from news where newsid between 1 and 2"""
C.execute(sql)
print 'ok'
sql =3D """select newsid from news where newsid between ? and ?"""
C.execute(sql, (1, 100))
print 'ok'
sql =3D """select newsid from news where newsid in (select newsid from
news
where newsid between 1 and 100)"""
C.execute(sql)
print 'ok'
sql =3D """select newsid from news where newsid in (select newsid from
news
where newsid between ? and ?)"""
C.execute(sql, (1, 100))
print 'ok'
<=3D=3D=3D=3D end of test_sql.py
=3D=3D=3D=3D> result
ok
ok
ok
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:/DOCUME~1/VKryukov/LOCALS~1/Temp/python-2320G8C", line 21, in
?
C.execute(sql, (1, 100))
mxODBC.ProgrammingError: ('37000', 0, '[Microsoft][ODBC SQL Server
Driver]Syntax error or access violation', 4469)
<=3D=3D=3D=3D end of result
----
Sincerely Yours, Victor V. Kryukov, UFG
phone: +7501 967 3727, ext. 4387
email: vkryukov@ufg.com