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
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