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: ProC fills varchar2 with blanks ???

Re: ProC fills varchar2 with blanks ???

From: Allen Kirby <akirby_at_RM_TO_REPLY.att.com>
Date: 1997/06/26
Message-ID: <33B2AF93.79E4@RM_TO_REPLY.att.com>#1/1

Bas Ven wrote:
>
> I declared a column as follows:
> name varchar2(128)
> and added a name to it : 'Bas'.
>
> When I get into sqlplus and retrieve the value of this column
> it displays is correctly -Bas- (no trailing spaces).
>
> When I fetch the same column using ProC, my C variable
> (declared as char name[128], initialized with:
> for (i=0;i<128;i++) name[i]=0; ) is filled with trailing spaces!
>

<snip>

Use a datatype of VARCHAR (or VARCHAR2, I can't remember - look it up) and you will get the following: name.arr - character array containing the data selected, with no trailing spaces, and name.len, which contains the actual number of bytes put into name.arr, in this case 3. Use name.len to null terminate name.arr, and there you have it. (name.arr[name.len] = '\0';) Now use name.arr as a string.

-- 
Allen Kirby			AT&T ITS Production Services
a k i r b y @ a t t . c o m	Alpharetta, GA.
-----
The views expressed are mine, not my employers.
Received on Thu Jun 26 1997 - 00:00:00 CDT

Original text of this message

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