pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: DanixDefcon5 <danixdefcon5@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Money deprecation and cast problem
Date: Tue, 25 Apr 2006 19:12:25 -0500 (EST)
Message-ID: <Pine.BSO.4.63.0604251905280.1400@leary2.csoft.net> (raw)
In-Reply-To: <1145905148.140026.134730@g10g2000cwb.googlegroups.com>
References: <1145905148.140026.134730@g10g2000cwb.googlegroups.com>



On Mon, 24 Apr 2006, DanixDefcon5 wrote:

> I know that the 'money' type is now deprecated, but I wonder why it is,
> and also ... how was it supposed to cast any other data type to 'money'
> anyway??? I checked the function list, per \df and couldn't find any
> function to do so, even though the money data type is basically an int4
> with the decimal point moved two places to the left. So....
>
> - Why did they deprecate it?

This is not a JDBC question.  The -general list would be more appropriate 
for this question.

When dealing with currency you are normally dealing with exact amounts and 
should be using the numeric type instead of a wrapper around int.
You shouldn't be able to do:

jurka=# select '$9.99'::money / 10.0;
----------
     $1.00
jurka=# select '$1,000,000'::money * 30;
-----------------
  -$12,949,672.96


Kris Jurka




view thread (2+ messages)

Message-ID: <Pine.BSO.4.63.0604251905280.1400@leary2.csoft.net>
Permalink:  ../Pine.BSO.4.63.0604251905280.1400@leary2.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.63.0604251905280.1400@leary2.csoft.net

 · 

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-jdbc@postgresql.org
  Cc: books@ejurka.com, danixdefcon5@gmail.com
  Subject: Re: Money deprecation and cast problem
  In-Reply-To: <Pine.BSO.4.63.0604251905280.1400@leary2.csoft.net>
  References: <1145905148.140026.134730@g10g2000cwb.googlegroups.com> <Pine.BSO.4.63.0604251905280.1400@leary2.csoft.net>

* 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