JDBC and BigDecimal problem

Поиск
Список
Период
Сортировка
От Peter Figuli
Тема JDBC and BigDecimal problem
Дата
Msg-id 1025626893.23160.29.camel@peposh
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Problem
Следующее
От: Peter Figuli
Дата:
Сообщение: Unicode collation error.