Re: inhibit rounding on numeric columns

From: Niklas Johansson <spot(at)tele2(dot)se>
To: "Horst Dehmer" <horst(dot)dehmer(at)inode(dot)at>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: inhibit rounding on numeric columns
Date: 2008-02-15 07:46:08
Message-ID: 385C643F-5671-4267-9E05-32B67D763BE3@tele2.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2008-02-15 07:53:54 Re: inhibit rounding on numeric columns
Previous Message Scott Marlowe 2008-02-15 07:42:29 Re: inhibit rounding on numeric columns