Re: DBI / DBD Informix -- Spaces in data
Posted in 1999
Informix padds all type CHAR columns with trailing spaces to full lenght.
ESQL/C has the STRING host variable datatype to cause the engine to
automatically strip the trailing spaces. I do not know if DBD/DBI Perl
supports STRING type host variables.
Art S. Kagel
Aaron Brooks wrote:
>
> I'm getting trailing spaces in my data fields in my DBI selects on
> informix data.
> Does anyone have a workaround or bug fix for this problem?
>
> I'm using perl version 5.005_03 built for i386-linux
> Red Hat Linux release 6.0 (Hedwig)
> Kernel 2.2.5-15 on an i686
> DBD - Informix.pm,v 60.6
> DBI.pm,v 10.25
>
> Example:
>
> Here's my table and data:
>
> create table cust (
> cust_num char(10),
> cust_name char(20)
> );>
> insert into cust values ("A15","John Doe")>
> Here's my perl code:
>
> $sql_stmt = "select cust_num, cust_name from cust where cust_num =
> \\"A15\\" ";
>
> my $cursor = ($dbh)->prepare($sql_stmt) || die $dbh->errstr;
> $cursor->execute || die $dbh->errstr;
>
> while ((@row) = $cursor->fetchrow()) {
> ($cust_num, $cust_name) = (@row);
> }
>
> print "[$cust_name]\\n";
>
> Results:
>
> [John Doe ]
>
> I don't want the trailing spaces. Even when no data is returned from
> a particular column, I get spaces in my fields.
>
> Thanks,
>
> Spaced Out