There appears to be a problem evaluating the contents of scalars values
which changed between perl 5.005.03 and 5.8.0. If perl evaluates the
contents of a scalar as an integer, even though it is a decimal, DBI/DBD
will later truncate the value of the scalar. 

Here's a small example:

#!/usr/local/bin/perl -w
use DBI;
use strict;

my $dbh = DBI->connect("DBI:Informix:sysmaster");
$dbh->do("create temp table test1( col1 decimal(16,2) )");

my $var = 1121.70;
if ( $var != 0 ) { print "Not Equal To 0\n"; }

print "BEFORE INSERT var=$var\n";
$dbh->do("insert into test1(col1) values(?)", undef, $var);
print "AFTER INSERT var=$var\n";

my $varout = $dbh->selectrow_array("select col1 from test1");
print "GOT BACK varout=$varout\n";
$dbh->disconnect;


Produces the following output:
Not Equal To 0
BEFORE INSERT var=1121.7
AFTER INSERT var=1121.7
GOT BACK varout=1121.00

Simply inserting the two lines below fixes the problem, I assume since it's
forcing perl to treat $var as a decimal.
$var += 0.001;
$var -= 0.001;

I've tested without success with perl 5.8.0 on AIX 4.3.3 and AIX 5.2.0 (both
threaded and non-threaded). I've also tested with DBI version 1.34 and 1.37
with the most recent version of DBD::Informix, but the example code works
fine with perl 5.005.03.

I've also tested creating a statement handle to do the insert and binding
the parameter to the statement handle, with the same problems.

Is there some way to tell DBI to determine what type of data is in a scalar
by examining it's contents rather than checking the flag to see how it was
last used?  

perl -V and DBI trace are shown below.

Thanks in advance,
-Darryl




Here's my perl -V:

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=aix, osvers=5.2.0.0, archname=aix
    uname='aix mtwac01 2 5 0001a16a4c00 '
    config_args='-Dprefix=/usr/local/perl5.8.0'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
-qmaxmem=16384 -qnoansialias -DUSE_NATIVE_DLOPEN -q32 -D_LARGE_FILES
-qlonglong',
    optimize=' ',
    cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384
-qnoansialias -DUSE_NATIVE_DLOPEN'
    ccversion='6.0.0.0', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -brtl -b32'
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lbind -lnsl -ldbm -ldl -lld -lm -lc -lcrypt -lbsd -lPW
    perllibs=-lbind -lnsl -ldl -lld -lm -lc -lcrypt -lbsd -lPW
    libc=/lib/libc.a, so=a, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='
-bE:/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/perl.exp'
    cccdlflags=' ', lddlflags=' -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp
-bE:$(BASEEXT).exp -bnoentry -lc'


Characteristics of this binary (from libperl): 
  Compile-time options: USE_LARGE_FILES
  Built under aix
  Compiled at Jul 14 2003 10:58:43
  @INC:
    /usr/local/perl5.8.0/lib/5.8.0/aix
    /usr/local/perl5.8.0/lib/5.8.0
    /usr/local/perl5.8.0/lib/site_perl/5.8.0/aix
    /usr/local/perl5.8.0/lib/site_perl/5.8.0
    /usr/local/perl5.8.0/lib/site_perl
    .


Here's the output of trace level 4:

    DBI 1.37-nothread dispatch trace level set to 4
    -> do for DBD::Informix::db (DBI::db=HASH(0x20133a48)~0x201c5560 'insert
into test1(col1) values(?)' undef 1121.7)
1   -> prepare for DBD::Informix::db (DBI::db=HASH(0x201c5560)~INNER 'insert
into test1(col1) values(?)' undef)
    New DBI::st (for DBD::Informix::st, parent=DBI::db=HASH(0x201c5560),
id=)
    dbih_setup_handle(DBI::st=HASH(0x201c5b58)=>DBI::st=HASH(0x201c5b10),
DBD::Informix::st, 201c5b64, Null!)
    dbih_make_com(DBI::db=HASH(0x201c5560), 20068478, DBD::Informix::st,
248, 0) thr#0
        -->> DBD::Informix::dbd_ix_st_prepare()
dbd_ix_st_prepare - no attribs set at
/usr/local/perl5.8.0/lib/site_perl/5.8.0/aix/DBD/Informix.pm line 180.
dbd_ix_st_prepare -- <<insert into test1(col1) values(?)>>
-->>dbd_ix_preparse(): <<insert into test1(col1) values(?)>>
<<--dbd_ix_preparse(): 1 placeholders
        -->> DBD::Informix::dbd_ix_setbindnum()
dbd_ix_setbindnum() ALLOCATE descriptor b_000000001
        <<-- DBD::Informix::dbd_ix_setbindnum()
number of described fields 1
dbd_ix_st_prepare() ALLOCATE descriptor d_000000001
        -->> DBD::Informix::dbd_ix_udts()
        <<-- DBD::Informix::dbd_ix_udts()
        -->> DBD::Informix::dbd_ix_blobs()
        <<-- DBD::Informix::dbd_ix_blobs()
dbd_ix_st_prepare'imp_sth->n_ocols: 1
        <<-- DBD::Informix::dbd_ix_st_prepare()
1   <- prepare= DBI::st=HASH(0x201c5b58) at DBI.pm line 1345 via crap.pl
line 22
    -> execute for DBD::Informix::st (DBI::st=HASH(0x201c5b58)~0x201c5b10
1121.7)
        -->> DBD::Informix::::st::dbd_ix_st_bind_ph()
        -->> DBD::Informix::::st::dbd_ix_st_bind_type()
---- dbd_ix_st_bind_type(): sql_type = 0
        <<-- DBD::Informix::::st::dbd_ix_st_bind_type()
        -->> DBD::Informix::dbd_ix_bindsv()
---- dbd_ix_bindsv() fld-indx = 1
---- dbd_ix_bindsv() inp-type = 13
dbd_ix_bindsv -- integer
        <<-- DBD::Informix::dbd_ix_bindsv()
        <<-- DBD::Informix::::st::dbd_ix_st_bind_ph()
        -->> DBD::Informix::dbd_ix_st_execute()
        -->> DBD::Informix::dbd_ix_exec()
---- EXECUTE p_000000001 USING b_000000001
        <<-- DBD::Informix::dbd_ix_exec()
        <<-- DBD::Informix::dbd_ix_st_execute()
    <- execute= 1 at DBI.pm line 1346 via crap.pl line 22
    -> rows for DBD::Informix::st (DBI::st=HASH(0x201c5b58)~0x201c5b10)
    <- rows= 1 at DBI.pm line 1347 via crap.pl line 22
    <> DESTROY ignored for outer handle DBI::st=HASH(0x201c5b58) (inner
DBI::st=HASH(0x201c5b10))
    -> DESTROY for DBD::Informix::st (DBI::st=HASH(0x201c5b10)~INNER)
        -->> DBD::Informix::dbd_ix_st_destroy()
-->> del_statement() 0x202100C8
dbd_ix_st_deallocate() DEALLOCATE DESCRIPTOR d_000000001
dbd_ix_st_deallocate() DEALLOCATE DESCRIPTOR b_000000001
del_statement() FREE statement p_000000001
<<-- del_statement() 0x202100C8
        <<-- DBD::Informix::dbd_ix_st_destroy()
    <- DESTROY= undef at crap.pl line 22
    dbih_clearcom 0x201c5b58 (com 0x202100c8, type 3) done.
    <- do= 1 at crap.pl line 22



____________________________________________________________________________
The information contained in this communication may be confidential, is
intended only for the use of the recipient named above, and may be legally
privileged.  If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, distribution, or copying of
this communication, or any of its contents, is strictly prohibited. If you
have received this communication in error, please re-send this communication
to the sender and delete the original message and any copy of it from your
computer system.
Thank you.

For more information please visit us at http://www.piperrudnick.com
____________________________________________________________________________


Reply via email to