PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: d dot desseaux at circo dot fr
Subject: lost precision with money columns read from perl/sybperl
Date: Apr 3 2003 9:01AM

Are you sure the bug N 261 "Money/Numeric potentially lose precision in
Sybase::CTlib", which had been corrected in version 2.11, is not back ?

My data are stored on an AIX4.3.3, with Sybase at 12.0.4 level.

Clients use Sybperl/CTlib version 2.15, either on IBM-RS6000 servers
(AIX4.3.3)
with perl 5.00503 and/or Linux/Mandrake (2.4.19) with perl 5.8.0.

Installed sybperl version
$ perl -M'Sybase::CTlib(999)'
Sybase::CTlib version 999 required--this is only version 2.15 at
/usr/lib/perl5/5.8.0/Exporter/Heavy.pm line 116.
BEGIN failed--compilation aborted.

Both configs give the same result : several precision lost for money
columns

One example :

From sqsh (or isql)

 select pognon from DESSDB..MES_SOUS
 go
 pognon
 -------------------
            -9476.35
                1.00
                2.00
                3.00
               -1.00
               -2.00
               -3.00

From the perl/SybPerl/CTlib script to be found at the end of this mail:
-9476.35000000003
1
2
3
-1
-2
-3

The problem :
Why did -9476.35 become -9476.35000000003 in perl ?

The script :
#!/bin/perl
use Sybase::CTlib;
$S = '!!!!!!!!!!!!!;
$U = 'did';
$P = '??????;
$F = 'money_bug';
$R = 'select pognon from DESSDB..MES_SOUS';

$dbh = new Sybase::CTlib ($U,$P,$S,$F);
@resul = $dbh->ct_sql($R);
foreach $Row(@resul)
{
        print "$Row->[0]\n";
}

Thanks in advance ...