[Zope-DB] ZOracleDA and CLOBs

Matthew T. Kromer matt@zope.com
Wed, 14 May 2003 09:45:28 -0400


Brian Brinegar wrote:

> I am using DCOracle2. I read this in the ZOracleDA readme. If I query 
> a table containing CLOBs using the test tab of an Oracle Connection I 
> get a error saying "__str__ returned non-string (type None)".  I have 
> inserted data into the CLOBs from Zope and I can read it out from 
> sqlplus.
>
> If I create a ZSQL Method that queries the table containing CLOBs and 
> use the test tab of that ZSQL method I get the same, "__str__ returned 
> non-string (type None)" error. If I change the maximum rows to one I 
> get back the results with "<LobLocator object at 0x14f05a98>" in place 
> of the LOB value.
>
> -Brian


I still think you may be using old software.

When I did a test just now, I did:


 >>> import DCOracle2
 >>> print DCOracle2.version 
(cvs release) -- DCOracle2 1.101 (dco2: 1.132 -DORACLE8i -DUSEOBJECT 
-Dlinux -DNATIVENUMERIC=1 -D_REENTRANT )
 >>> db = DCOracle2.connect('scott/tiger')
 >>> print db.decodedesc(db.describe('CLOB_TEST'))
SCOTT.CLOB_TEST table
        NAME column  VARCHAR2(64)
        DATA column  CLOB
 >>> c = db.cursor()
 >>> lob = db.LobLocator("SQLT_CLOB")
 >>> f = open('src/dco2.c')
 >>> lob.write(f.read())
201685
 >>> c.execute('insert into clob_test values (:1, :2)', 'dco2.c', lob)
4
 >>> lob = db.LobLocator("SQLT_CLOB")
 >>> f = open('README')
 >>> lob.write(f.read())
4672
 >>> c.execute('insert into clob_test values (:1, :2)', 'README', lob)
4
 >>> db.commit()

Then in the TEST tab of Zope's ZOracleDA I was able to SELECT * FROM 
CLOB_TEST and get the names and values back.

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