PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re:
Date: Apr 9 2003 5:45PM

On Tue, 2003-04-08 at 19:30, xiujian.lin@hsbc.co.jp wrote:

> How to keep data in Money format in the result of a sql query using
> SYBASE::CTlib?
> I have tried set "UseMoney" attribute to dbh, but it seems not working, it
> stills shows, for example, 200000 instead of 200,000. Here is my sample
> script:

The 200,000 format is something that is handled by the client - it's
actually a string format.

Currently sybperl doesn't handle this format directly, but you can do it
yourself like this (taken from the "Perl Cookbook", O'Reilly):

sub commify {
    my $text = reverse $_[0];
    $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
    return scalar reverse $text;
}

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
mpeppler@peppler.org                 http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or 
long term contract positions - http://www.mbay.net/~mpeppler/resume.html