Hello monks.. I connect to a database through this script to pull out the values from the database and write them to a text file. The database looks like this:
BA 1/1/2005 12/31/2999 11.3700000000000016 BO 1/1/2005 12/31/2999 7.5400000000000000 EQ 1/1/2005 12/31/2999 12.0700000000000000 FI 1/1/2005 12/31/2999 3.0000000000000000 MO 1/1/2005 12/31/2999 3.8000000000000000 SP 1/1/2005 12/31/2999 12.9900000000000000
My script looks like:
use warnings; use strict; use DBI; use POSIX qw(strftime); my $currSysDate =strftime ("%m/%d/%Y", localtime); my $currYear =strftime("%Y", localtime); my $dbh; my $dsn = "dbi:Oracle:hod3"; my $user = 'dbo'; my $password = 'dbo'; my $mffundclass; my $mfstartdate; my $mfenddate; my $mfror; my $mdstartdate; my $mdenddate; my $mddiscountrate; if($currSysDate eq "06/29/$currYear"){ open ROR, ">>RORTableValues_Nav.txt" or die "Error in opening RORT +ableValues_Nav.txt"; open DISCOUNT, ">>DiscountRateTableValues_Nav.txt" or die "Error i +n opening DiscountRateTableValues_Nav.txt"; printf ROR ("MF_FUND_CLASS \t MF_START_DATE \t MF_END_DATE \t MF_R +OR \n"); printf DISCOUNT ("MD_START_DATE \t MD_END_DATE \t MD_DISCOUNT_RATE + \n"); $dbh = DBI->connect($dsn, $user, $password, {PrintError => 1, Rais +eError => 1}) or die ("Can't execute statement: $DBI::errstr\n"); my $sql = qq{select * from T_LIMF_MRD_FUND_ROR}; my $sth = $dbh->prepare($sql); $sth->execute(); $sth->bind_columns(\$mffundclass,\$mfstartdate,\$mfenddate,\$mfror +); while ($sth->fetch()){ print "$mffundclass \t $mfstartdate \t $mfenddate \t $mfror \n +"; printf ROR "$mffundclass \t $mfstartdate \t $mfenddate \t $mfr +or \n"; }; $sth->finish(); my $sql1 = qq{select * from T_LIMD_MRD_DISCOUNT_RATE}; my $sth1 = $dbh->prepare($sql1); $sth1->execute(); $sth1->bind_columns(\$mdstartdate,\$mdenddate,\$mddiscountrate); while ($sth1->fetch()){ printf DISCOUNT "$mdstartdate \t $mdenddate \t $mddiscountrate + \n"; }; $sth1->finish(); $dbh->disconnect(); }
Now this script instead of giving the 4th column exactly as it is rounds of the value and returns the rounded value. What changes do I need to make to get the exact values. Thanks Neshat

In reply to Getting rounded off values from database. by Nesh

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.