Re: Money casting too liberal? - Mailing list pgsql-general

From Jasen Betts
Subject Re: Money casting too liberal?
Date
Msg-id kj2af2$tif$1@gonzo.reversiblemaps.ath.cx
Whole thread Raw
In response to Money casting too liberal?  (Steve Crawford <scrawford@pinpointresearch.com>)
Responses Re: Money casting too liberal?
List pgsql-general
On 2013-03-28, D'Arcy J.M. Cain <darcy@druid.net> wrote:
>
> I would like to see the type handle other situations such as foreign
> (to me) currency, etc.  I suppose a positional parameter and a currency
> string setting would handle most of those issues.  Technically, the
> money type is a cents type.  Everything is stored as the number of
> cents.  Formatting it as dollars and cents is a convenience added by
> the I/O functions.

it actually does that, if you have the locale installed you can set
LC_MONETARY to  Japan  and get no decimals and a Yen symbol
or to UAE and get three decimals and their currency symbol.

> Even as the author I sometimes go with numeric but there is a place for
> the type.  If you are working with simple dollars and cents quantities
> and you need to do lots of calculations on them, the money type can be
> a great performance boost.  The big win that money brings is that
> everything is stored as an int.  That means that you don't need to
> convert data in the database to a machine representation before
> summing, averaging, etc.  The machine can generally work on the data as
> it comes out of the DB.

it'd be nice to be able to do a money * numeric operation

currently multiplication is done in floating point and this can give
unexpected results.

>
> --
> D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
> http://www.druid.net/darcy/                |  and a sheep voting on
> +1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
> IM: darcy@Vex.Net, VOIP: sip:darcy@Vex.Net
>
>


--
⚂⚃ 100% natural

pgsql-general by date:

Previous
From: "Severn, Chris"
Date:
Subject: ts_tovector() to_query()
Next
From: Kevin Grittner
Date:
Subject: Re: ts_tovector() to_query()