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

From: Jennifer R. Amon <bamon_at_ocvaxc.cc.oberlin.edu>
Date: Fri, 03 Jun 1994 15:30:02 -0500
Message-ID: <bamon-030694153002_at_amon.cc.oberlin.edu>


In article <2smmp3$g1m_at_gaia.cc.gatech.edu>, badri_at_cc.gatech.edu (badri) wrote:

> VARCHAR y;
> char x;
>
> EXEC SQL DECLARE ....
>
> FETCH Cursor_Name INTO :a, :b, :y;
>
> x = y.arr
>
> OR
> char x[1];
> x[0] = *y.arr
>
> ORACLE cries. How to get around this?

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.


Jennifer R. Amon            PHONE: (216) 775-6987
Houck Computing Center        FAX: (216) 775-8573
Oberlin College
Oberlin, OH 44074        INTERNET: bamon_at_ocvaxc.cc.oberlin.edu
_____________________________________________________________________
Received on Fri Jun 03 1994 - 22:30:02 CEST

Original text of this message