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