Re: mx.ODBC error: Invalid Descriptor Index

"M.-A. Lemburg" <[email protected]>
Newsgroups gmane.comp.python.egenix.user
Organization eGenix.com Software GmbH; http://www.egenix.com/
Message-ID <[email protected]>
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
eGenix.com

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
               http://www.egenix.com/company/contact/


_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.