Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: OCI question: about null string
"music4" <cli4_at_lucent.com> wrote in message news:<as43ld$a7d_at_netnews.proxy.lucent.com>...
> Dear all,
>
> This is a question about OCI.
>
> I have a field of VARCHAR typed, and it can be null or empty string. I write
> a OCI function using C language to select this field value. If the field is
> null, or empty string, I always get a error "ORA-01405: fetched colum value
> is NULL". So I have to use something like "NVL(the_field, '-9')" to get an
> alternate string. But here is it possible to let OCI just put a empty string
> in buffer (char [] typed). I tried "NVL(the_field, '')", it didn't work.
First off, a trip to tahiti.oracle.com is in order to look up the error message.
ORA-01405 fetched column value is NULL
Cause: The INTO clause of a FETCH operation contained a NULL value, and no indicator was used. The column buffer in the program remained unchanged, and the cursor return code was +2. This is an error unless you are running Oracle with DBMS=6, emulating version 6, in which case it is only a warning.
Action: You may do any of the following:
My guess is that you're not providing OCI with an indicator variable when you bind your char* buffer. This is the only way for OCI to tell you that you've fetched a NULL value (it doesn't change the data in the buffer you've passed in, so the buffer is likely to have garbage in it unless you've initialized it).
Justin Received on Fri Nov 29 2002 - 15:53:27 CST