Home » Developer & Programmer » Precompilers, OCI & OCCI » Oracle OCI8 fetch of nvarchar2 column returning no data
Oracle OCI8 fetch of nvarchar2 column returning no data [message #94264] Wed, 23 June 2004 08:31 Go to next message
Nicholas Gray
Messages: 13
Registered: November 2000
Junior Member
I'm currently trying to migrate a program working with OCI8 on varchar2 data to nvarchar2.
Database columns have been converted and now hold the corresponding UTF-16 values.

OCIEnvNlsCreate has been used:
int rc = (*OCIEnvNlsCreate_p) (&envhp, OCI_THREADED&#124OCI_NO_UCB, (dvoid *)0, 0, 0, 0, (size_t) 0, (dvoid **)0, OCI_WE8ISO8859P1_ID, OCI_UTF16ID);

Statement in the form of:
Select Column1, Column2, Column3, Column4 From TestTable
has been prepared

Corresponding buffers for the values have been set up and defined:
*pRlen = (ub2)0;
*pRcode = (ub2)OCI_SUCCESS;
ub2 csid = OCI_UTF16ID;
ub1 cform = SQLCS_NCHAR;

res = checkForError((*OCIDefineByPos_p) ( stmthp, &defhp[[pos]], errhp, pos, (dvoid *) pBuf, bufl, ftype, &indhp[[pos]], pRlen, pRcode, OCI_DEFAULT ));

if (res == OCI_SUCCESS && ftype == SQLT_STR && charset == SQLCS_NCHAR)
{
res = checkForError((*OCIAttrSet_p) ( (dvoid *) defhp[[pos]],
(ub4) OCI_HTYPE_DEFINE, (void *) &csid, (ub4) 0,
(ub4) OCI_ATTR_CHARSET_ID, errhp ));
res = checkForError((*OCIAttrSet_p) ( (dvoid *) defhp[[pos]],
(ub4) OCI_HTYPE_DEFINE, (void *) &cform, (ub4) 0,
(ub4) OCI_ATTR_CHARSET_FORM, errhp ));
}

however once fetch returns columns 1 and 3 return a result len of 0 and their buffers hold no data while columns 2 and 4 work as they should.
All 4 columns hold the same data, are of equal length and type.

Anyone got an idea what it is that I'm missing and how to fix it ?

PS: It's an Oracle 9.0.2 database and no error whatsoever is returned or written to any log file.

Thanks in advance.
Re: Oracle OCI8 fetch of nvarchar2 column returning no data [message #94265 is a reply to message #94264] Wed, 23 June 2004 08:52 Go to previous messageGo to next message
Nicholas Gray
Messages: 13
Registered: November 2000
Junior Member
err make that 9.2.0.3
Re: Oracle OCI8 fetch of nvarchar2 column returning no data [message #94288 is a reply to message #94265] Thu, 01 July 2004 01:25 Go to previous message
Nicholas Gray
Messages: 13
Registered: November 2000
Junior Member
nevermind ... looks like the result buffer needs to be 2 byte aligned
Previous Topic: Declare Cursor error in pro*c
Next Topic: Good online Pro C manuals or "quick help", glossary, definition of terms, etc
Goto Forum:
  


Current Time: Thu Sep 20 03:31:41 CDT 2018