pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Wright <mwright@pro-ns.net>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Type Conversion: int4 -> Money
Date: Fri, 10 Sep 1999 09:35:38 -0500
Message-ID: <001701befb99$c345c450$c62812ac@markw_compaq> (raw)


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






view thread (7+ messages)  latest in thread

Message-ID: <001701befb99$c345c450$c62812ac@markw_compaq>
Permalink:  ../001701befb99$c345c450$c62812ac@markw_compaq/
Also on:    postgresql.org/message-id/001701befb99$c345c450$c62812ac@markw_compaq

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: mwright@pro-ns.net
  Subject: Re: [SQL] Type Conversion: int4 -> Money
  In-Reply-To: <001701befb99$c345c450$c62812ac@markw_compaq>
  References: <001701befb99$c345c450$c62812ac@markw_compaq>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox