[egenix-users] mx.ODBC error: Invalid Descriptor Index

M.-A. Lemburg mal at egenix.com
Thu Apr 15 21:57:02 CEST 2010

Alexandre Fayolle wrote:
> On Tuesday 13 April 2010 12:03:27 M.-A. Lemburg wrote:
>> """
>> * For any ODBC or Transact-SQL statement containing a parameter in a HAVING
>>  clause, or compared to the result of a SUM function.
>> * For any ODBC or Transact-SQL statement depending on a subquery containing
>>  parameters.
> So this would be why I get a failure for 
> SELECT DISTINCT rel_require_permission0.eid_to
> FROM require_permission_relation AS rel_require_permission0
> WHERE rel_require_permission0.eid_from=? 
> AND NOT EXISTS(SELECT 1 FROM require_permission_relation AS 
> rel_require_permission1 WHERE rel_require_permission1.eid_from=? 
> AND rel_require_permission0.eid_to=rel_require_permission1.eid_to) 
> correct? 

Yes. You have a sub-select in there. We've also had reports of
the same problems if a VIEW is used in the WHERE clause (views
essentially are sub-selects as well).

>> Since SQL Server's ODBC driver supports SQL type binding, this
>> is what mxODBC uses per default.
>> cursor.executedirect() is a way to work around that default on
>> a per-statement basis. It forces mxODBC to use Python type binding
>> for that statement.
> But if I read the documentation correctly, doing this won't prepare the 
> statement, which will worsen the perfs if the statement is reused a lot. 

True, but with SQL Server it's usually better to run performance
tests and then decide. More recent versions of SQL Server do
some smart caching on the server side to avoid having to
rerun the expensive prepare step.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Apr 15 2010)
>>> 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 our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the egenix-users mailing list