scale parameter to setObject method

From: Bob Bruynooghe <rubbish(dot)bin1(at)mac(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: scale parameter to setObject method
Date: 2008-09-05 12:14:51
Message-ID: DE105EF3-6E2B-475F-8255-0065E78A96E3@mac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I am calling the method setObject(int parameterIndex, Object x, int
targetSqlType) with NUMERIC as the targetSqlType and a BigDecimal
value of -92233720368.54775 as x. I expected the value placed in the
database to have no fractional part. In fact the database contains
-92233720368.54775. (Checked by both a JDBC query and using psql.)
The prepared statement I am using is

INSERT INTO alltypes (key, short, int, long, bigdecimal, float,
double) ( ?, ?, ?, ?, ?, ?, ? )

and, the table was created using

CREATE TABLE alltypes (key smallint PRIMARY KEY, short smallint, int
integer, long bigint, bigdecimal numeric, float real, double double
precision)

I have also tried using the method setObject(int parameterIndex,
Object x, int targetSqlType, int scale) and setting the scale
explicitly. The value of scale is being ignored.

I had a quick look at code for void setObject(int parameterIndex,
Object x, int targetSqlType, int scale) in AbstractJdbc2Statement in
the CVS repository. It looks to me like the scale parameter is not
used within the method. If I have understood the code correctly then I
would expect the behaviour I am seeing. However, I don't think that is
the behaviour that the spec defines. Am I understanding things
correctly?

The server is PostgreSQL 8.2.5 and the JDBC driver is
postgresql-8.3-603.jdbc3.

regards

Bob Bruynooghe

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message TNO 2008-09-05 16:06:26 Problem With Euro character
Previous Message Richard Broersma 2008-09-02 22:01:54 JDBC driver feature implementation lists