Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Wierd problem? Does C pad a host variable in embedded SQL with spaces?

Re: Wierd problem? Does C pad a host variable in embedded SQL with spaces?

From: George Claborn <gclaborn_at_us.oracle.com>
Date: Thu, 16 Apr 1998 09:47:42 -0400
Message-ID: <35360BFE.1567733A@us.oracle.com>


laz777_at_semaphore.com wrote:

> >
> > I am using C on a Sun Unix Enterprise Server with embedded sql.
> >
> > A select statement is used as follows
> >
> > select laborcode, craft fro labor into :laborcode, craft when la2 =
> > :empnum
> >
> > Then an
> > insert into labtrans (laborcode, craft) values (:laborocode,
> :craft);
> >
> > :laborcode is defined as char laborcode[17] in the program;
> >
> > The laborcode field in the labor table is a variable (VAR_CHAR) field in
> > Oracle of up to 16 characters.
> >
> > The problem is that the resulting laborcode in labtrans is always 16
> > characters long. If the selected laborcode from labor is less (i.e. JEDRF)
> > then it padds the field with spaces to equal 16 characters. Is this a
> > function of the embedded sql in C? Or of Oracle
> >
>

Hi,
Another approach that shouldn't require code changes on your part is to use the Pro C Precompiler option CHAR_MAP=STRING (vs. the default, CHAR_MAP=VARCHAR2). The datatype STRING is just like VARCHAR2 except its null-term, rather than blank padded. The CHAR_MAP=STRING option will cause all host char[n] declarations to be mapped to type STRING and they'll get null-termed on output. Refer to Chapter 3 of the Pro C/C++ Precompiler Programmer's Guide.

Regards, George Claborn (Oracle Utilities) Received on Thu Apr 16 1998 - 08:47:42 CDT

Original text of this message

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