Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A3F0F635889 for ; Tue, 19 Jan 2010 11:15:44 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 29939-01 for ; Tue, 19 Jan 2010 15:15:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outbound.vnet-inc.com (outbound.vnet-inc.com [216.146.104.103]) by mail.postgresql.org (Postfix) with ESMTP id 3318463537F for ; Tue, 19 Jan 2010 11:15:33 -0400 (AST) Received: from [192.168.157.32] (unknown [216.129.226.118]) by outbound.vnet-inc.com (Postfix) with ESMTP id 33BA259D0 for ; Tue, 19 Jan 2010 08:15:29 -0700 (MST) Message-ID: <4B55C8D3.7090907@ttc-cmc.net> Date: Tue, 19 Jan 2010 07:59:31 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060417 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Mapping Java BigDecimal References: <4B540B7D.1080306@b2bcentrum.cz> <4B541C40.9040206@postnewspapers.com.au> <407d949e1001180209v39e46a88v6d5a0e5a181a5d84@mail.gmail.com> <4B55371B.40105@postnewspapers.com.au> <407d949e1001190304m1bfea314ta5bd89e035d01c9@mail.gmail.com> In-Reply-To: <407d949e1001190304m1bfea314ta5bd89e035d01c9@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.185 tagged_above=-10 required=5 tests=BAYES_40=-0.185 X-Spam-Level: X-Archive-Number: 201001/51 X-Sequence-Number: 20247 Yesterday I indirectly, but did not completely demonstrate the difference between the BigDecimal and Numeric data types in the databases. My example indicated the precision is carried and return in the default when no precision is given for Numeric, but more importantly: postgres=# CREATE TEMP TABLE test (x numeric, y numeric(19, 2)); CREATE TABLE postgres=# INSERT INTO test VALUES ('3.48', '3.48'); INSERT 0 1 postgres=# INSERT INTO test VALUES ('0.056', '0.056'); INSERT 0 1 postgres=# SELECT SUM(x), SUM(y) FROM test; sum | sum -------+------ 3.536 | 3.54 (1 row) As indicated PostgreSQL kept the precision and rounded for the specified y column to the precision defined. The unspecified precision column x just kept on adding precision decimal places. If you chop either the x or y column decimal places you will get the whole Integer 3. The same process in Oracle for the summing with a BigDecimal data type I suspect most likely will return 4. The BigDecimal is a BigInteger rounded to the specified precision. Quite a difference creature than the Numeric(19, 2) in PostgreSQL, which is real with rounding to the precision specified, not to the nearest whole Integer. Perhaps this whole mapping question should be put over to the database forum for an appropriate answer to BigDecimal to what in PostgreSQL. danap.