pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
HELP !     With Money type
3+ messages / 3 participants
[nested] [flat]

* HELP !     With Money type
@ 2004-07-23 12:36  Terry Hampton <thampton@limacorp.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Terry Hampton @ 2004-07-23 12:36 UTC (permalink / raw)
  To: pgsql-admin




	Everyone,

	Just ran across an odd situation.
	I have defined a field:

  amount       | money                    | not null default ''

	Works fine until the dollar amounts get
	very large  -  into the tens of millions.
	At that point, the actual amount stored
	becomes very unpredictable.

	I just saved a record via a simple
	front end App.  I entered 56,000,000
	When I retrieved the record i got:
		$13,050,327.04  !!

	Any thoughts ?

		ENVIRONMENT:
			Linux 2.4.20-20.7smp
			psql (PostgreSQL) 7.2.3

		Thank you,
		Terry
			

-- 
Terry L. Hampton
Project Manager
LimaCorp, LLC   www.limacorp.com
513.587.1874





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: HELP !     With Money type
@ 2004-07-23 13:20  Oliver Elphick <olly@lfix.co.uk>
  parent: Terry Hampton <thampton@limacorp.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliver Elphick @ 2004-07-23 13:20 UTC (permalink / raw)
  To: Terry Hampton <thampton@limacorp.com>; +Cc: pgsql-admin

On Fri, 2004-07-23 at 13:36, Terry Hampton wrote:
> 
> 	Everyone,
> 
> 	Just ran across an odd situation.
> 	I have defined a field:
> 
>   amount       | money                    | not null default ''
> 
> 	Works fine until the dollar amounts get
> 	very large  -  into the tens of millions.
> 	At that point, the actual amount stored
> 	becomes very unpredictable.
> 
> 	I just saved a record via a simple
> 	front end App.  I entered 56,000,000
> 	When I retrieved the record i got:
> 		$13,050,327.04  !!
> 
> 	Any thoughts ?

The Money type is deprecated.  It uses a floating point representation,
which is not good for precise values.

Use DECIMAL instead - e.g. DECIMAL(12,2)




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: HELP ! With Money type
@ 2004-07-23 14:13  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Oliver Elphick <olly@lfix.co.uk>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2004-07-23 14:13 UTC (permalink / raw)
  To: olly@lfix.co.uk; +Cc: Terry Hampton <thampton@limacorp.com>; pgsql-admin

Oliver Elphick <olly@lfix.co.uk> writes:
> The Money type is deprecated.  It uses a floating point representation,
> which is not good for precise values.

Actually the underlying storage is integer (int4), which is precise but
has a very limited range.  Terry is seeing overflows (which are
evidently not being tested for :-().

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-07-23 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-23 12:36 HELP !     With Money type Terry Hampton <thampton@limacorp.com>
2004-07-23 13:20 ` Oliver Elphick <olly@lfix.co.uk>
2004-07-23 14:13   ` Re: HELP ! With Money type Tom Lane <tgl@sss.pgh.pa.us>

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