[egenix-users] cursor.specialcolumns

M.-A. Lemburg mal at lemburg.com
Mon Dec 30 19:07:06 CET 2002


Michael Rothwell wrote:
> I've been reading the mxODBC docs, and the ODBC docs (at MSDN), and I 
> can't seem to get cursor.specialcolumns() to yield a result set. I'm 
> trying it against a table with a primary key, and an identity field. The 
> default arguments are as follows:
> 
> specialcolumns(qualifier=None,owner=None,table=None,
>   coltype=SQL.BEST_ROWID,scope=SQL.SCOPE_SESSION,
>   nullable=SQL.NO_NULLS)
> 
> Unfortunately, the ODBC docs say this:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_s_8q2b.asp 
> 
>   When requesting row identifiers (IdentifierType SQL_BEST_ROWID),
>   SQLSpecialColumns returns an empty result set (no data rows) for any
>   requested scope other than SQL_SCOPE_CURROW. The generated result set
>   indicates that the columns are only valid within this scope.
> 
> So, I do this:
> cursor.specialcolumns (table="MyTable", scope=0)
> 
> I use zero because I'm not sure how to get access to "SQL.SCOPE_CURROW". 

The SQL singleton object is defined at mxODBC subpackage level,
e.g. on Windows you'd write:

mx.ODBC.Windows.SQL.SCOPE_CURROW

> No results. I tried running a query that selects a single column, and 
> then run specialcolumns. No result set.
> 
> How might I get specialcolumns() to tell me what the special columns for 
> a table are?

This could be caused by the defaults for qualifier and owner.
When set to None these are translated to SQL NULL values and
should result in a match-any query. However, some drivers
require different values to result in this meaning, e.g. an
empty string or '%'.

I'd suggest to first get a feeling for how to specify a
table in the database using e.g. cursor.columns() before
trying to find the right parameters for .specialcolumns().

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/




More information about the egenix-users mailing list