Re: Pro*C Question *******************

From: Tim Smith <tssmith_at_netcom.com>
Date: Sat, 4 Jun 1994 12:54:12 GMT
Message-ID: <tssmithCqvIID.Hx3_at_netcom.com>


bamon_at_ocvaxc.cc.oberlin.edu (Jennifer R. Amon) writes:
>VARCHAR is actually a structure, part of which is an array of characters.
>You need:
 

>VARCHAR y[2];
>char x;
 

>FETCH cursor_name INTO :a, :b, :y;
 

>y.arr[y.len] = 0; /* null terminate the string */
>x = y.arr[0];
 

>Notice that you need to use the length or an indicator variable to
>check for null return values on the fetch, because your y.arr string can
>contain data from the previous fetch if the fetch actually returned null.

This last is a good point. I'd just like to add that using an indicator is the best practice. On the Oracle precompilers I've tried (all 7 of them) a 0 length is returned if a null is fetched, but I don't believe that Oracle guarantees this. The indicator variable != 0 for a null *is* guaranteed, so that's your safest bet.

--Tim (tssmith_at_oracle.com) Received on Sat Jun 04 1994 - 14:54:12 CEST

Original text of this message