Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 942962E0035 for ; Fri, 15 Feb 2008 03:46:17 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 18786-01 for ; Fri, 15 Feb 2008 03:46:11 -0400 (AST) Received: from mail.codecraft.se (unknown [84.19.128.181]) by postgresql.org (Postfix) with ESMTP id AE4CB2E002C for ; Fri, 15 Feb 2008 03:46:13 -0400 (AST) Received: from [85.230.2.42] (c-2a02e655.631-1-64736c10.cust.bredbandsbolaget.se [85.230.2.42]) by mail.codecraft.se (Postfix) with ESMTP id CEAA514CBF6; Fri, 15 Feb 2008 08:46:10 +0100 (CET) In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v753) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <385C643F-5671-4267-9E05-32B67D763BE3@tele2.se> Cc: Content-Transfer-Encoding: 7bit From: Niklas Johansson Subject: Re: inhibit rounding on numeric columns Date: Fri, 15 Feb 2008 08:46:08 +0100 To: "Horst Dehmer" X-Mailer: Apple Mail (2.753) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/112 X-Sequence-Number: 30203 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