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: Wierd problem Does C or Oracle pad a host variable with spaces in embedded SQL?

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

From: Michael Krolewski <vandra_at_u.washington.edu>
Date: Tue, 14 Apr 1998 00:12:45 -0700
Message-ID: <35330C6D.9C62A05C@u.washington.edu>


Actually it is highly unlikely that Oracle would automatically pad a variable. However if the source : select laborcode ... is a char(16) then the value would alway be padded. Ansi standard / Version 7 code will by default use the char data type, not varchar2. You need to explicitly select varchar2.

create table x (field1 varchar2(16), field2 char(16)) // explicit

create table x as select textField1, textField2 from someotherTable; // implicit, should

                    be char of appropriate length.

Mike Krolewski

Tony 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
>
> Please respond to ramdan_at_mailexcite.com
Received on Tue Apr 14 1998 - 02:12:45 CDT

Original text of this message

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