When working with money data type I am getting the output only upto two decimals places (rounded off) when using DBI and DBD::Sybase.

Is their a setting which can give me the output upto 4 decimals just like isql.


The code is :

#!/usr/bin/perl

use DBI;
use DBD::Sybase;

$dbh = DBI->connect("dbi:Sybase:", $ENV{"LOGNAME"}, "");
$sth = $dbh->prepare("
create table #t (mm money, ii decimal(10,4))
insert into #t(mm, ii) values(1234.4485, 45678.9898)
select mm, ii from #t
");
$sth->execute;

@row = $sth->fetchrow_array();
print join("|", @row), "\n";

output is :
1234.45|45678.9898


I can use the convert function it gives the correct output but in generic
programs using select * from table is more efficient then select col1, col2
..... from table.

modified program

#!/usr/bin/perl

use DBI;
use DBD::Sybase;

$dbh = DBI->connect("dbi:Sybase:", $ENV{"LOGNAME"}, "");
$sth = $dbh->prepare("
create table #t (mm money, ii decimal(10,4))
insert into #t(mm, ii) values(1234.4485, 45678.9898)
select convert(decimal(10, 4), mm), ii from #t
");
$sth->execute;

@row = $sth->fetchrow_array();
print join("|", @row), "\n";

output is :
1234.4485|45678.9898