[Zope-DB] Clob's in DCOracle2: works, but can't read

Matthew T. Kromer matt at bane.mi.org
Mon Jul 19 11:11:00 EDT 2004


Bogdan M. Maryniuck wrote:

>Hi again.
>Please help me where I am wrong, using clob's as IN/OUT in
>DCOracle2 stored procedures?
>
>OK, here is the chunk of some source:
>-------------------------------------------------
>d = DCOracle2.connect( ... )
>c = d.cursor()
>
>clob = d.LobLocator('SQLT_CLOB')
>clob.write(msg) # msg is an text
>try:
>    out = c.procedure.my_package.my_procedure(input_clob = clob, output_clob = '')
>    print "SUCCESS"
>except:
>    out = None
>    print "FAILURE"
>
>print type(out)
>print dir(out)
>print out.length()
>print out.read()
>-------------------------------------------------
>
>...and here is its output:
>-------------------------------------------------
>SUCCESS
><type 'LobLocator'>
>['length', 'read', 'trim', 'write']
>54380
>Traceback (most recent call last):
>  File "clobprocedure.py", line 34, in ?
>    print out.read()
>dco2.DatabaseError: (0, 'p^\x14\x08t\xef\xff\xbf\xd06\x03@\xd8\xbb\x0b\x08\xd06\x03@\xd8\xbb\x0b')
>-------------------------------------------------
>
>As far as I can see, there is "RaiseOCIError" called in dco2.c:
>-------------------------------------------------
>    if (_LobLocator_length(self, &loblength) != 0)
>            return RaiseOCIError(self->errhp, OCI_HTYPE_ERROR);
>-------------------------------------------------
>
>And here is last lines from the tracelog:
>-------------------------------------------------
>* 1090244988.950, 161, OCIAttrGet, 0x08159898, OCI_HTYPE_STMT,
>* 0xbffff008, OCI_ATTR_ROW_COUNT, *
>* 1090244988.950, 162, OCIAttrGet, 0, 1, *
>* 1090244988.950,  18, Cursor_execute, 8, *
>* 1090244988.950,  17, Cursor_getattr, 0x0815a708, 0x0810fc3c ?=
>* rowcount, *
>* 1090244988.950,  18, Cursor_getattr, 0x0815a708, *
>* 1090244988.951,  17, Cursor_rowcount, 0x0815a708, *
>* 1090244988.951,  18, Cursor_rowcount, 0x080c0108, 1, *
>* 1090244988.951,  17, Cursor_getattr, 0x0815a708, 0x080fbcbc ?=
>* describe, *
>* 1090244988.951,  18, Cursor_getattr, 0x0815a708, *
>* 1090244988.951,  17, Cursor_describe, 0x0815a708, 0x080c2384, *
>* 1090244988.951,  18, Cursor_describe, *
>* 1090244988.951,  17, LobLocator_getattr, 0x08113860, 0x080ccabc ?=
>* read, *
>* 1090244988.951,  18, LobLocator_getattr, 0x080db900, *
>* 1090244988.952,  17, LobLocator_read, 0x08113860, 0x080c2384, *
>* 1090244988.952,  65, LobLocator_read, -1, 1, 0, 1, *
>* 1090244988.952,  17, _LobLocator_length, 0x08113860, *
>* 1090244988.952,  33, OCILobGetLength, 0x0813e2e4, *
>* 1090244988.952,  34, OCILobGetLength, 0, *
>* 1090244988.953,  66, _LobLocator_length, 299, *
>* 1090244988.953,  18, _LobLocator_length, 0, *
>* 1090244988.953,  33, OCILobRead, 0x0813e2e4, 299, 1, 0x080e5304, *
>* 1090244988.954,  34, OCILobRd, 99, *
>
>* 1090244988.954,  36, RaiseOCIError, 135324032, 0xbfffefa4 ?= ����t, *
>                                      ^^^^^^^^^ exactly this number I got as an error!
>
>* 1090244988.956,  17, Cursor_dealloc, 0x08156ea8, *
>* 1090244988.956, 161, OCIHandleFree, OCI_HTYPE_STMT, 0x0815520c, *
>* 1090244988.956, 162, OCIHandleFree, 0, *
>* 1090244988.956, 161, OCIHandleFree, OCI_HTYPE_ERROR, 0x0815a1f4, *
>* 1090244988.957, 162, OCIHandleFree, 0, *
>* 1090244988.957,  18, Cursor_dealloc, *
>-------------------------------------------------
>
>Who can explain me what means "135324032" error and why it would not
>like to read my clob?
>
>RDBMS:    Oracle8i
>OS:       Linux SuSE SLES
>DCOracle: CVS snapshot *before* crisw
>
>  
>

Errors like that are really invalid handles.  What it means for some 
reason is that the handle it tried to use on a call was invalid.  The 
routine RaiseOCIError doesn't get the actual status code of the result 
which almost for sure was an invalid handle status code.

It *could* be that you need the database to allocate and return the LOB 
you want for you with the EMPTY_CLOB() function, e.g. "SELECT 
EMPTY_CLOB() AS CLOB FROM DUAL" 


More information about the Zope-DB mailing list