Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> OCI Oracle 8.1.7 Question about OCIFetch & BLOB fields

OCI Oracle 8.1.7 Question about OCIFetch & BLOB fields

From: Tomislav <shaka_at_envox.hr>
Date: Fri, 15 Feb 2002 19:05:20 +0100
Message-ID: <MRLN526712FC18@merlin.envox.hr>


Configuration: MS Win2k SP2, MS Visual C++ 6.0 SP6, Oracle 8.1.7 via OCI

OCIEnv is initialized via OCI_OBJECT.

I want to execute user defined SELECT statement via: 1) OCIStmtExecute( m_hpContext, m_hpStatement, m_hpErr, 0, 0, NULL, NULL, OCI_DEFAULT ) without any rows returning for now, just using implicit describe of columns, I use combination of
2) OCIParamGet( ) and OCIAttrGet() to get OCI_ATTR_NAME, OCI_ATTR_DATA_TYPE, OCI_ATTR_DATA_SIZE. After that I use:
3) OCIDefineByPos to define output values and allocate memory for their return.

At the end:
4) OCIStmtFetch( m_hpStatement,m_hpErr,1,wFlag, OCI_DEFAULT) will get me one row of any kind of data.

Everything works as expected, except when I have a BLOB, CBLOB, any kind of LOB field in the select statement. Then, I have a problem. Reading through some online doc & samples, I could only find examples of reading BLOBs if they are already expected in a statement. But no example if the statement is unknown in advance.
So I tried this in the place of (3):

OCILobLocator* pLobLocator = NULL;

If OCI_ATTR_DATA_TYPE = SQLT_BLOB (for example),

use OCIDescriptorAlloc( m_hpInheritedEnv, (void**)& pLobLocator, OCI_DTYPE_LOB, 0, NULL ) and then OCIDefineByPos( m_hpStatement, &pFieldAttr, m_hpErr, nColumnCount, pLobLocator, -1, wOciType, NULL, NULL, 0, OCI_DEFAULT )

When my code comes to (4), OCIStmtFetch causes access violation C0005 in ORACLIENT8.DLL module. I know that I must be doing something wrong. I don't know what size to put in OCIDefineByPos, so I copied -1 from some documentation examples.

If (4) should succeed I would use OCILobGetLength & OCILobRead functions to read lob from descriptor.

But how to get that descriptor transfered through OCIStmtFetch?

I would appreciate some hints or help on this subject!

--
--

Tomislav.

"Real sharpness comes without effort,
No growth without assistance,
No action without reaction,
Now give yourself up and find yourself again."
--

"Crouching tiger, hidden dragon" Received on Fri Feb 15 2002 - 12:05:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US