DBI / DBD Informix -- Spaces in data

DBI / DBD Informix -- Spaces in data

Post by Aaron Brook » Sun, 31 Dec 1899 09:00:00



  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;



   }

   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

 
 
 

DBI / DBD Informix -- Spaces in data

Post by Art S. Kage » Sun, 31 Dec 1899 09:00:00


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


>   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;



>    }

>    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


 
 
 

DBI / DBD Informix -- Spaces in data

Post by Douglas Wils » Sun, 31 Dec 1899 09:00:00


man DBI
see the 'ChopBlanks' attribute.


>  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?

Not a bug. That's what informix does for CHAR columns.

Hope that helps,
Douglas Wilson

 
 
 

1. Indexes via DBI driver in Perl (DBD::Informix)

...mainly because it isn't something that DBI supports directly.

Your best bet is probably to go to the IIUG software archives
(hmm, how many times have I said this today?  http://www.iiug.org)
and get hold of SQLCMD.  In the code for the INFO statements
(sqlinfo.ec), you will find the statements I use to generate the
information loosely equivalent to "INFO INDEXES FOR sometable",
which is not a built-in command in SQL so you cannot run it
directly from DBD::Informix.  Note that the statements assume
you know the table number (systables.tabid) entry for the table.
To deal with lists of tables, you will have to revise the code
slightly.

--
Yours,

Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
     "I don't suffer from insanity; I enjoy every minute of it!"

2. help, Solid jdbc

3. DBI and DBD::Informix installation problems

4. MsSQL 6.0 Error

5. DBI/DBD for INFORMIX-SE 7.24.UC5 for Linux Redhat

6. Need Help on SYN BASE 4.9.1 Installation...

7. DBD-Informix and DBI

8. OIDs overflow

9. DBI/DBD-informix, value of a new serial after insert

10. Informix & DBD::DBI

11. Perl DBI-0.93 DBD-Informix-0.58 on SCO

12. Strange behavior of DBD/DBI Informix

13. Strange behavior of DBI/DBD::Informix