pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Todd Shoemaker <jtshoe11@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Default numeric scale of zero in JDBC?
Date: Thu, 18 Jan 2007 06:05:42 -0800 (PST)
Message-ID: <20070118140542.61505.qmail@web53601.mail.yahoo.com> (raw)

Hello,

I have discovered that the jdbc driver apparently uses a default scale of zero decimal places for SQL numeric operators, including the sum() aggregate operator.  For example, this query:

select (1.5 + 2);

This returns 4 from jdbc, but it returns 3.5 when run from within PGAdmin.  The only way I can coerce the value to return decimal places is to explicity cast the value to a numeric with scale:

select cast(1.5 + 2 as numeric(10,2)) as value

This returns 3.5.  

Also, queries like "select sum(value) from table" returns a rounded value, even though the column 'value' is numeric(16,2).  Is there 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 to explicitly cast them.   Have others have encountered this issue?

Thanks,

-Todd








view thread (3+ messages)  latest in thread

Message-ID: <20070118140542.61505.qmail@web53601.mail.yahoo.com>
Permalink:  ../20070118140542.61505.qmail@web53601.mail.yahoo.com/
Also on:    postgresql.org/message-id/20070118140542.61505.qmail@web53601.mail.yahoo.com

 · 

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 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: jtshoe11@yahoo.com
  Subject: Re: Default numeric scale of zero in JDBC?
  In-Reply-To: <20070118140542.61505.qmail@web53601.mail.yahoo.com>
  References: <20070118140542.61505.qmail@web53601.mail.yahoo.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