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: money format
Date: Apr 10 2003 12:43AM

[Note - you should probably join the sybperl-l mailing list]

On Wed, 2003-04-09 at 17:24, owner-sybperl-l@peppler.org wrote:

> Thank you. That's what we have been doing using commify subroutine, but I
> was just wondering what we can do with UseMoney attribute, because in the
> manual, it says "If TRUE, keep MONEY data retrieved via ct_fetch() in
> native format instead of converting the data to double precision floating
> point." and I thought the native format is Money format, something like
> "200,000".

No - the native "money" format is an 8 byte integer (in binary format)
with an implied decimal point in the fourth position from the right.

This is how "money" data is handled natively in C or C++ using the
cs_calc() routines, to avoid any loss of precision which is inherent
with using floating point data.

The UseMoney attribute has nothing to do with how the values are
displayed.

Michael


> Michael Peppler  on 10 Apr 2003 02:45
> 
> To:   Sybperl-L Mailing List 
> cc:   Xiujian LIN/TKY/IBJP/HSBC@HSBC
>                                                                      
>                                                                      
>                                                                      
>  Our Ref:               Your Ref:                                    
>                                                                      
> 
> 
> Subject:  Re:
> 
> 
> 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
> 
> 
> ---------------------------------------------------------------------
> "This message originated from the Internet. Its originator may or
> may not be who they claim to be and the information contained in
> the message and any attachments may or may not be accurate."
> ---------------------------------------------------------------------
> 
> 
> 
> 
> ************************************************************
> HSBC Securities (Japan) Ltd, Tokyo
> HSBC Building, 11-1, Nihonbashi 3-chome,
> Chuo-ku, Tokyo 103-0027, Japan
> ************************************************************
> 
> 
> 
> 
> ________________________________________________________________________
> The information contained in this e-mail is confidential. It may also be legally privileged.
> If you are not the addressee you may not copy, forward, disclose or use any part of it.
> If you have received this message in error, please delete it and all copies from your system
> and notify the sender immediately by return e-mail.
> E-mail communications cannot be guaranteed to be timely secure, error or virus-free. The sender does not accept liability for any errors or omissions which arise as a result.
> ________________________________________________________________________
-- 
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