Re: float bug? perl 5.8, DBI and oracle 10.2.0



Hello folk!

Now I think I got a clean shot at what's troubling me 8-)
Consider the following code:

---------------------<snip>--------------------------
use strict;
use warnings;
use DBI;

my $ORASID = $ENV{ORACLE_SID};
my $ORAUSR = 'username';
my $ORAPWD = 'password';

sub showbin {
print "bin: ".unpack("B70",reverse pack("d",$_[0]))."\n";
}

my $v1 = "1.73696";
showbin($v1);

print "connecting\n";
my $DBC = DBI->connect("dbi:Oracle:$ORASID",$ORAUSR,$ORAPWD,
{ PrintError=>0, AutoCommit=>0 } );

my $v2 = "1.73696";
showbin($v2);

---------------------<snip>--------------------------

This code simply opens a connection toward an oracle database. And
shows the binary representation of the string "1.73696" converted into
a native float (NV) before and after we opened the connection.

When I run it with perl 5.6.2, DBI 1.38 and DBD::Oracle 1.17, it says:

[HEAD] ~/HEAD/test/t> !967$ /opt/perl-5.6.2/bin/perl 04_test1.t
bin: 0011111111111011110010101001011010010001101001110101110011010001
connecting
bin: 0011111111111011110010101001011010010001101001110101110011010001

When I run it with perl 5.8.8, DBI 1.58 and DBD::Oracle 1.19, it says:

[HEAD] ~/HEAD/test/t> !969$ /opt/perl-5.8.8/bin/perl 04_test1.t
bin: 0011111111111011110010101001011010010001101001110101110011010001
connecting
bin: 0011111111111011110010101001011010010001101001110101110011010000

See how the least significant bit (last one on the right) changes in
the last run?
There we have it. It is what caused the problems I have been spamming
you all with for the last few days :)

Conclusion: on my host (perl 5.8 etc.), the line:

my $DBC = DBI->connect("dbi:Oracle:$ORASID",$ORAUSR,$ORAPWD,
{ PrintError=>0, AutoCommit=>0 } );

seems to alter the way perl parses the string "1.73696". This later
resulted in arithmetic errors that looked like floating point related
issues but were not.

Has anyone any idea of what's happening here????

/Erwan
.



Relevant Pages

  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... use DBI; ... This code simply opens a connection toward an oracle database. ... When I run it with perl 5.6.2, DBI 1.38 and DBD::Oracle 1.17, it says: ... bin: 0011111111111011110010101001011010010001101001110101110011010001 ...
    (perl.dbi.users)
  • Re: DBD::Sybase context allocation routine failed
    ... DBI will take care of loading and initialising the module. ... attempting a DB connection using a brand new installation of perl ... perl -MDBI -e 'print DBI- ... The context allocation routine failed. ...
    (perl.dbi.users)
  • Re: Perl 6 DBI API ideas
    ... Though I didn't raise my hand when you asked for people to contribute to a DBI module for Perl 6, I've had some ideas that I thought about sharing. ... I would also love to see some standardization on the driver names ("mysql" when it's normally written ... DBI is supposed to be query language agnostic, even if SQL is the most commonly used group of languages, and if a user can declare this explicitly, it saves the driver from having to guess what they were given, which might be ambiguous. ...
    (perl.dbi.users)
  • Re: RDB limitations: from Jimmy Gavan
    ... Your DBI QUESTION: ... Bearing in mind no compiler to reference or even test my thoughts, ... The unique Id is used as a DB connection ... move SQLSTATE to MOST-SQLSTATE ...
    (comp.lang.cobol)
  • Problem of DBI build
    ... I installed Oracle Application Server 4.0.8.2 included perl module. ... I need to installe DBI and DBD::Oracle module. ... You can install them any time after installing the DBI. ... line 318: error 1705: Function prototypes are an ANSI feature. ...
    (perl.dbi.users)