From: | "Yonatan Ben-Nes" <yonatan(at)epoch(dot)co(dot)il> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Numeric or Integer for monetary values? |
Date: | 2006-12-11 15:50:44 |
Message-ID: | 2d0127b80612110750r38b10c1cx5156916c86b7b775@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-12-11 16:06:47 | Re: search_path when restoring to new db |
Previous Message | SunWuKung | 2006-12-11 15:35:13 | search_path when restoring to new db |