Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 20A5C9FA1D8 for ; Thu, 18 Jan 2007 13:13:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 65911-06 for ; Thu, 18 Jan 2007 13:13:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from web53608.mail.yahoo.com (web53608.mail.yahoo.com [206.190.37.41]) by postgresql.org (Postfix) with SMTP id 57FB89FB314 for ; Thu, 18 Jan 2007 13:05:52 -0400 (AST) Received: (qmail 88506 invoked by uid 60001); 18 Jan 2007 17:05:51 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=55kch1yfbflRkWt00R/DGMvdujV2+ArbTrl4eYTq4cYUs8hcy1VdZH+/vah3tjEz5SIjDbQPrF31LFz6NjgXsHXxmbkA2+oYqIsjstLz5WSbzOhOTj8U/jfDjKaC+Rq94R+zvgal1ZQRiFT5jXvn1VrJln+poU7Hkj8YXZLJclw= ; Message-ID: <20070118170551.88504.qmail@web53608.mail.yahoo.com> Received: from [208.254.250.196] by web53608.mail.yahoo.com via HTTP; Thu, 18 Jan 2007 09:05:51 PST Date: Thu, 18 Jan 2007 09:05:51 -0800 (PST) From: Todd Shoemaker Reply-To: Todd Shoemaker Subject: Re: Default numeric scale of zero in JDBC? To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.585 tagged_above=0 required=5 tests=AWL, BAYES_40, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: * X-Archive-Number: 200701/117 X-Sequence-Number: 16482 Hello,=0A=0AI downloaded the jdbc source and noted that if I specified a de= fault scale of 4 in AbstractJdbc2ResultSetMetadata.getScale() (if the colum= n is numeric and the scale is -1), I received the desired results. I furth= er updated the code to provide a private DEFAULT_NUMERIC_PRECISION that def= aults to 4, which can be overridden with the System property org.postgresql= .jdbc2.DEFAULT_NUMERIC_SCALE. I built this and tested it within Squirrel S= QL and it works properly, and the system property is working to override th= is default. Would this be an update that the jdbc driver developers would = be interested in?=0A=0AI suppose my other question is, what do other JDBC d= rivers default this to? Also, does this imply that others do not use non-i= nteger arithmetic with sql through JDBC?=0A=0A-Todd=0A=0A----- Original Mes= sage ----=0AFrom: Todd Shoemaker =0ATo: pgsql-jdbc@post= gresql.org=0ASent: Thursday, January 18, 2007 8:05:42 AM=0ASubject: [JDBC] = Default numeric scale of zero in JDBC?=0A=0AHello,=0A=0AI have discovered t= hat the jdbc driver apparently uses a default scale of zero decimal places = for SQL numeric operators, including the sum() aggregate operator. For exa= mple, this query:=0A=0Aselect (1.5 + 2);=0A=0AThis returns 4 from jdbc, but= it returns 3.5 when run from within PGAdmin. The only way I can coerce th= e value to return decimal places is to explicity cast the value to a numeri= c with scale:=0A=0Aselect cast(1.5 + 2 as numeric(10,2)) as value=0A=0AThis= returns 3.5. =0A=0AAlso, queries like "select sum(value) from table" retu= rns a rounded value, even though the column 'value' is numeric(16,2). Is t= here a magic vmparam or setting to default the precision at the jdbc driver= level? I am trying to run a large existing system on PostgreSQL and it is= not feasible to hunt down all numeric operations in thousands of classes t= o explicitly cast them. Have others have encountered this issue?=0A=0ATha= nks,=0A=0A-Todd=0A=0A=0A=0A=0A=0A=0A---------------------------(end of broa= dcast)---------------------------=0ATIP 5: don't forget to increase your fr= ee space map settings=0A=0A=0A=0A=0A