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

In reply to Re: Wrong calculation result with data retrieved with DBD::InterBase from view by pilcrow
in thread Wrong calculation result with data retrieved with DBD::InterBase from view by stefbv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.