BigInt in per

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have a MSSQL database with bigint datatype. I am doing a simple SELECT
query and printing out the information:

  my $qry = "SELECT C1, C2 FROM TABLE" ;
  my $sth = $dbh->prepare($qry);
   while(my @row = $sth->fetchrow_array) {
    print "$row[0]\t$row[1]\n";


954925604786    1.00000000076029e+15
954925505262    1.00000000076023e+15
954925581159    1.00000000076028e+15
954925581160    1.00000000076028e+15
954925421109    1.00000000076019e+15
954925574965    1.00000000076027e+15
110978984447583 1.00000000076031e+15

In the Database:
954925604786  1000000000760290

any idea, how to convert the output?



Re: BigInt in per

Tux Tango wrote:
Quoted text here. Click to load it

Maybe you are looking for printf?


Re: BigInt in per

Quoted text here. Click to load it

You might want to use the bignum prama in your Perl script:

   use bignum;

Re: BigInt in per

Quoted text here. Click to load it

Apparently the output *is* converted - from MSSQL bigint to a perl
floating point number. So I guess your question is really how you can
*prevent* this conversion. You probably can't (using bigint in Perl
probably doesn't help because this conversion occurs somewhere in the
DBD driver), but you can convert to a string instead:

  my $qry = "SELECT to_char(C1), to_char(C2) FROM TABLE" ;

or something similar (to_char() is oracle-specific, afaik) should help.


Site Timeline