Skip site navigation (1) Skip section navigation (2)

JDBC and BigDecimal problem

From: Peter Figuli <peposh(at)peposh(dot)sk>
To: pgsql-bugs(at)postgresql(dot)org
Subject: JDBC and BigDecimal problem
Date: 2002-07-02 16:21:33
Message-ID: 1025626893.23160.29.camel@peposh (view raw or flat)
Thread:
Lists: pgsql-bugs
Dear JDBC team,

I'm using pgjdbc2.jar from february and facing this problem:
I have a table (UNICODE database is set up) having numeric type in it.
Than something like this:

statement = connection.preparedStatement( "SELECT * from account WHERE
rate > ?" );
statement.setBigDecimal( 1, BigDecimal.valueOf( 120, 2 ));

produces postgresql error:
ERROR: Unable to identify an operator '>' for numeric and double
precision.

Because we use some data object persistent software, there is a problem 
force program to do any cast for it.

My simple hack is based on fact that:
SELECT * from account WHERE rate > '1.2'; 
avoids double conversion of '1.2' I changed:
org.postgresql.jdbc2.PreparedStatement.java on line 254 (
setBigDecimal(...)) from:
set(parameterIndex, x.toString()); to:
set(parameterIndex, "'"+x.toString()+"'");

All seems to work properly now.


Nice day 

Peposh











pgsql-bugs by date

Next:From: Tom LaneDate: 2002-07-02 19:03:57
Subject: Re: Problem
Previous:From: Peter FiguliDate: 2002-07-02 16:11:06
Subject: Unicode collation error.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group