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.