Numeric or Integer for monetary values?

Поиск
Список
Период
Сортировка
От Yonatan Ben-Nes
Тема Numeric or Integer for monetary values?
Дата
Msg-id 2d0127b80612110750r38b10c1cx5156916c86b7b775@mail.gmail.com
обсуждение исходный текст
Ответы Re: Numeric or Integer for monetary values?  ("Brandon Aiken" <BAiken@winemantech.com>)
Re: Numeric or Integer for monetary values?  (Jorge Godoy <jgodoy@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Re: Hi
Следующее
От: Tom Lane
Дата:
Сообщение: Re: search_path when restoring to new db