Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Wrong calculation result with data retrieved with DBD::InterBase from view

by pilcrow (Sexton)
on Mar 23, 2010 at 16:24 UTC ( [id://830321]=note: print w/replies, xml ) Need Help??


in reply to Wrong calculation result with data retrieved with DBD::InterBase from view

DBD-InterBase 0.48 appears to have a bug in converting high-scale data. You can work around it by explicitly CAST()ing your "faulty" column in your VIEW definition to something like NUMERIC(18, 5)

I filed this as rt.cpan #55841. In my tests, any NUMERIC/DECIMAL with a scale >= 10 is corrupted:

#! /usr/bin/perl # perl t.pl dbi:InterBase:dbname=... user pass use DBI; use strict; use warnings; my $dbh = DBI->connect(@ARGV[0..2], {RaiseError => 1}); for my $scale (1 .. 17) { my $cast = "CAST(19 AS NUMERIC(18, $scale))"; my ($r) = $dbh->selectrow_array("select $cast FROM rdb\$databa +se"); print "$cast ...... $r\n"; }
This prints:
CAST(19 AS NUMERIC(18, 1)) ...... 19 CAST(19 AS NUMERIC(18, 2)) ...... 19 CAST(19 AS NUMERIC(18, 3)) ...... 19 CAST(19 AS NUMERIC(18, 4)) ...... 19 CAST(19 AS NUMERIC(18, 5)) ...... 19 CAST(19 AS NUMERIC(18, 6)) ...... 19 CAST(19 AS NUMERIC(18, 7)) ...... 19 CAST(19 AS NUMERIC(18, 8)) ...... 19 CAST(19 AS NUMERIC(18, 9)) ...... 19 CAST(19 AS NUMERIC(18, 10)) ...... -88.1021438976 CAST(19 AS NUMERIC(18, 11)) ...... -884.01624455168 CAST(19 AS NUMERIC(18, 12)) ...... -8847.001212166144 CAST(19 AS NUMERIC(18, 13)) ...... -88475.0001384243200 CAST(19 AS NUMERIC(18, 14)) ...... -884756.00000957530112 CAST(19 AS NUMERIC(18, 15)) ...... -8847564.000000985366528 CAST(19 AS NUMERIC(18, 16)) ...... -88475644.0000001263730688 CAST(19 AS NUMERIC(18, 17)) ...... -884756445.00000001899888640

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://830321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-18 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found