Re: inhibit rounding on numeric columns
От | Niklas Johansson |
---|---|
Тема | Re: inhibit rounding on numeric columns |
Дата | |
Msg-id | 385C643F-5671-4267-9E05-32B67D763BE3@tele2.se обсуждение исходный текст |
Ответ на | inhibit rounding on numeric columns ("Horst Dehmer" <horst.dehmer@inode.at>) |
Список | pgsql-sql |
On 15 feb 2008, at 08.28, Horst Dehmer wrote: > Is there an easy way to enforce strict handling of numeric values > with scales, i.e. raise an exception/error instead of rounding > values to the specified scale? > insert into dummy values(3.141); -- insert #1 > insert into dummy values(3.1415); -- insert #2 > insert into dummy values(3.14159); -- insert #3 > insert into dummy values('3.14159'); -- insert #4 > I wonder if there is a generic/transparent way (say a config > parameter) to force postgresql to raise an error for inserts #3 and > #4. I don't know a way to achieve what you ask for, and I'm not sure I think there should be. Have you thought about the consequences of treating 3.1415 as being different from 3.1415000? If you do a SELECT 3.1415 = 3.1415000 it will always evaluate to true, which it should, no matter to which precision you cast the operands. Numeric scale is not the equivalent of character string length. What is the actual problem you're trying to solve? Sincerely, Niklas Johansson
В списке pgsql-sql по дате отправления: