Re: [SQL] Type Conversion: int4 -> Money
Re: [SQL] Type Conversion: int4 -> Money
От:
"Mark Wright" <mwright@pro-ns.net>
Дата:
-----Original Message-----
From: secret
To: Herouth Maoz
Cc: pgsql-sql@postgreSQL.org
Date: Thursday, September 09, 1999 3:31 PM
Subject: Re: [SQL] Type Conversion: int4 -> Money
>Herouth Maoz wrote:
>
...
> Perl... I ended up writing my own formatting function... It has one
that
>does ####.## however not one that'll do the nice 123,456.33 ... :) Do you
know
>if there are any public modules that do such things?
from the Perl Cookbook (a Perl-programmer must have!): sub commify { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; }
If you want a locale-using solution, and can use C, there's code in the
pgsql source that does this. Look at:
/src/backend/utils/adt/cash.c cash_out()