Re: [SQL] Type Conversion: int4 -> Money

From: "Mark Wright" <mwright(at)pro-ns(dot)net>
To: <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] Type Conversion: int4 -> Money
Date: 1999-09-10 14:35:38
Message-ID: 001701befb99$c345c450$c62812ac@markw_compaq
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


-----Original Message-----
From: secret <secret(at)kearneydev(dot)com>
To: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
Cc: pgsql-sql(at)postgreSQL(dot)org <pgsql-sql(at)postgreSQL(dot)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()

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-09-10 14:45:14 Re: [SQL] runaway backend process
Previous Message Bruce Momjian 1999-09-10 13:31:00 Re: [SQL] runaway backend process