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 -> Re: using OCIRowidToChar

Re: using OCIRowidToChar

From: Harald Maier <maierh_at_myself.com>
Date: Wed, 20 Aug 2003 20:30:44 +0200
Message-ID: <m3n0e4yyej.fsf@ate.maierh>

deevandeevan_at_hotmail.com (yy343) writes:

> Hi
>
> I am trying to use OCIRowidToChar with a select for update statement.
>
> After the call to
> OCIStmtExecute,
> I call
>
> OCIRowid * rowid;
> /* allocate descriptor with OCIDescriptorAlloc() */
> status = OCIDescriptorAlloc ((dvoid *) envhp, (dvoid **) &rowid,
> (ub4) OCI_DTYPE_ROWID, (size_t) 0, (dvoid **) 0);
>
> status = OCIAttrGet ((dvoid*) stmthp, OCI_HTYPE_STMT,
> (dvoid*) rowid, (ub4 *) 0, OCI_ATTR_ROWID, (OCIError *) errhp);
>
> and then
> unsigned char * rowIDstring = new unsigned char[128];
> ub2 rowIDLength = 0;
> if ((status = OCIRowidToChar(rowid, rowIDstring, &rowIDLength, errhp))
> != OCI_SUCCESS)
> {
> checkerr(errhp, status);
> return status;
> }
>
> The problem is that the call to OCIRowidToChar returns the following
> error:
> "ORA-01405: fetched column value is NULL"
>
> How can I work around this problem? If I run the query manually (in
> sqlplus without the for update) then I get 1 row back, so why is the
> rowid null?

Is it possible that the error happens _before_ OCIRowidToChar? The error 01405 normally happens if a 'fetch into' contains a null value. Look for the fetched columns if one of them contains null values. Personally, I like in this situation the function _nvl_.

Harald Received on Wed Aug 20 2003 - 13:30:44 CDT

Original text of this message

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