Not an Informix guy, but this looks like a formatting issue.  What happens if you use 
printf() with a format mask for the float values?

--
Ron Reidy
Lead DBA
Array BioPharma, Inc.


-----Original Message-----
From:   Rutherdale, Will [mailto:[EMAIL PROTECTED]
Sent:   Thu 9/9/2004 3:58 PM
To:     [EMAIL PROTECTED]
Cc:     
Subject:        Losing Precision from FLOAT
Hi.

I'm reasonably experienced with Perl and with databases but new to Perl-DBI.

I'm trying to write a conversion program from a legacy DB at work and
discovered that some values weren't copied accurately.  The columns involved
are declared FLOAT.  

It's an Informix DB running on Solaris.

I've mocked up a test table with data and code to distill the problem to
something analysable.

Schema:
create table abc
(
    id int not null,
    val float
);

Data:
$ echo "select * from abc" | dbaccess pncabc
. . .
         id            val 

          0 1.234567893700
          1 2.897430129800

Code:
    my ( $sth ) = $dbh->prepare( qq{SELECT id, val FROM abc} );
    $sth->execute();
    while ( my ( $id, $val ) = $sth->fetchrow_array() )
    {
        print STDERR "id==$id, val==$val\n";
    }

Result:
id==0, val==1.23456789
id==1, val==2.89743013

As you can see, data in the 'val' column is using >=10 digits of precision,
but this gets rounded off to only 9 digits when the query returns.

My questions:
- where and why is the precision lost?
- how can I coerce DBI into giving me more precision?

Any help would be greatly appreciated.

-Will


     - - - - - - -  Appended by Scientific-Atlanta, Inc.  - - - - - - -  
This e-mail and any attachments may contain information which is confidential, 
proprietary, privileged or otherwise protected by law. The information is solely 
intended for the named addressee (or a person responsible for delivering it to the 
addressee). If you are not the intended recipient of this message, you are not 
authorized to read, print, retain, copy or disseminate this message or any part of it. 
If you have received this e-mail in error, please notify the sender immediately by 
return e-mail and delete it from your computer.





This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is intended 
to be for the use of the individual or entity named above. If you are not the 
intended recipient, please be aware that any disclosure, copying, distribution 
or use of the contents of this information is prohibited. Please notify the
sender  of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.

Reply via email to