Numeric or Integer for monetary values? - Mailing list pgsql-general

From Yonatan Ben-Nes
Subject Numeric or Integer for monetary values?
Date
Msg-id 2d0127b80612110750r38b10c1cx5156916c86b7b775@mail.gmail.com
Whole thread Raw
Responses Re: Numeric or Integer for monetary values?  ("Brandon Aiken" <BAiken@winemantech.com>)
Re: Numeric or Integer for monetary values?  (Jorge Godoy <jgodoy@gmail.com>)
List pgsql-general
Hi all,

I need to decide which data type should I make for monetary values, shall I use Numeric data type to hold values like "9.52" or is it better to keep it as an integer with value in cents like "952"?

I know that at the manual it's written about the Numeric data type that "It is especially recommended for storing monetary amounts and other quantities where exactness is required.", but I'm wondering what will happen at cases when I got $1.01 to divide between 2 entities at 50% each, if both will get 51 cents or 50 cents it will be a mistake.

The calculation procedure will probably be made with PL/pgSQL, actually maybe it doesn't even matter what the data type is (Integer/Numeric) as long as I make enough validations for the result?

Cheers!
  Ben-Nes Yonatan

pgsql-general by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Re: Hi
Next
From: Tom Lane
Date:
Subject: Re: search_path when restoring to new db