What steps will reproduce the problem?
import pyodbc
db = pyodbc.connect ("...")
q = db.cursor ()
q.execute ("SELECT ?", [None])
q.fetchall ()
What is the expected output? What do you see instead?
Expected: [(None,)]
Instead: pyodbc.Error: ('07009', '[07009] [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (0) (SQLDescribeParam); [42000] [Micros
oft][ODBC SQL Server Driver]Syntax error or access violation (0)')
What version of the product are you using? On what operating system?
pyodbc 2.1.8 (strictly: a git clone) on Python 2.6 WinXP SP3 against MSSQL 2005
Please provide any additional information below.
This is a regression; the code used to work in pyodbc 2.0.x. The problem occurs when SQLDescribeParam is called within GetParamType in params.cpp. This is presumably because SQL Server can't determine a type for the parameter.
The error code is unfortunately a fairly general one which would cover circumstances other than this so it's not possible simply to filter it out at this point. (Altho' the code does work if you ignore the error and return VARCHAR).
Labels: Python2