[DB-SIG] Parameters in DCOracle2

Matthew T. Kromer matt@zope.com
Wed, 21 Aug 2002 09:45:11 -0400

James Briggs wrote:

>3) Tweak or Force DCOracle2, or the interface of your choic,e to convert string bind variables to CHAR datatypes not VARCHAR datatypes, using DCOracle2.TypeCoercion??? Not sure this is possible, I haven't had access to a database to test this yet. I do know in the C layer it is possible to define arrays to be mapped to the CHAR type...

Yes, that will work.  Here's an example:

SQL> describe testchar
 Name                                      Null?    Type
 ----------------------------------------- -------- 
 ID                                                 NUMBER(38)
 CS                                                 CHAR(12)
 VC                                                 VARCHAR2(12)

SQL> select * from testchar;

        ID CS           VC
---------- ------------ ------------
         1 MATT         MATT

import DCOracle2
db = DCOracle2.connect('scott/tiger')
c = db.cursor()
c.execute('select * from testchar where cs=:1',
    DCOracle2.TypeCoercion('MATT', 'SQLT_AFC'))

print c.fetchall()

However, its fairly nonobvious that 'SQLT_AFC' (ANSI Fixed Character) is 
the type you get when you use datatype 'CHAR' -- you'd expect that to be 
'SQLT_CHR' but that's VARCHAR.

Matt Kromer
Zope Corporation  http://www.zope.com/