From: Greg Stark <gsstark@mit.edu>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: Jakub Bednář <jakub.bednar@b2bcentrum.cz>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Mapping Java BigDecimal
Date: Mon, 18 Jan 2010 10:09:28 +0000
Message-ID: <407d949e1001180209v39e46a88v6d5a0e5a181a5d84@mail.gmail.com> (raw)
In-Reply-To: <4B541C40.9040206@postnewspapers.com.au>
References: <4B540B7D.1080306@b2bcentrum.cz>
<4B541C40.9040206@postnewspapers.com.au>
On Mon, Jan 18, 2010 at 8:30 AM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
> I don't know whether Oracle or Pg are more "correct" here - you're
> giving Pg "3" so arguably it shouldn't assume "3.00" and should in fact
> return "3". OTOH, you've told it what the scale and precision are for
> the column, and inputs to the column should be presumed to fit that
> scale and precision.
>
It doesn't really work that way. Whether you store "3" or "3.00" or
"3.0000" you're storing the same value in the numeric field.
The precision and scale you specify for Postgres is just the maximum
as well. But it's also used for the default formatting when converting
to text. If you retrieved the numeric in binary format it would be the
same regardless of the parameters.
In no case does postgres remember the precision of the input text. If
you don't specify a precision on the column it just prints as many as
necessar. That sounds like what you're looking for.
--
greg
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: gsstark@mit.edu, craig@postnewspapers.com.au, jakub.bednar@b2bcentrum.cz
Subject: Re: Mapping Java BigDecimal
In-Reply-To: <407d949e1001180209v39e46a88v6d5a0e5a181a5d84@mail.gmail.com>
References: <4B540B7D.1080306@b2bcentrum.cz> <4B541C40.9040206@postnewspapers.com.au> <407d949e1001180209v39e46a88v6d5a0e5a181a5d84@mail.gmail.com>
* 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