pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Niklas Johansson <spot@tele2.se>
To: Horst Dehmer <horst.dehmer@inode.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: inhibit rounding on numeric columns
Date: Fri, 15 Feb 2008 08:46:08 +0100
Message-ID: <385C643F-5671-4267-9E05-32B67D763BE3@tele2.se> (raw)
In-Reply-To: <E1JPuyj-0007vC-6J@smartmx-12.inode.at>
References: <E1JPuyj-0007vC-6J@smartmx-12.inode.at>


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



view thread (4+ messages)  latest in thread

Message-ID: <385C643F-5671-4267-9E05-32B67D763BE3@tele2.se>
Permalink:  ../385C643F-5671-4267-9E05-32B67D763BE3@tele2.se/
Also on:    postgresql.org/message-id/385C643F-5671-4267-9E05-32B67D763BE3@tele2.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spot@tele2.se, horst.dehmer@inode.at
  Subject: Re: inhibit rounding on numeric columns
  In-Reply-To: <385C643F-5671-4267-9E05-32B67D763BE3@tele2.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox