Re: Mapping Java BigDecimal

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Mapping Java BigDecimal
Дата
Msg-id hj4kvq$2jf$1@ger.gmane.org
обсуждение исходный текст
Ответ на Re: Mapping Java BigDecimal  (Craig Ringer <craig@postnewspapers.com.au>)
Список pgsql-jdbc
Craig Ringer, 19.01.2010 05:37:
>> 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.
>
> Then I'm confused:
>
> regress=> create table test (x numeric);
> CREATE TABLE ^
> regress=> insert into test (x) values ('3');
> INSERT 0 1
> regress=> insert into test (x) values ('3.0');
> INSERT 0 1
> regress=> insert into test (x) values ('3.00');
> INSERT 0 1
> regress=> insert into test (x) values ('3.000');
> INSERT 0 1
> regress=> select * from test;
> x
> -------
> 3
> 3.0
> 3.00
> 3.000
> (4 rows)
>

My first question: why does anyone pass a numeric value as a string ;)

But it does not seem to matter whether a real value (without quotes) or a string is used for the above example.

I also tested this with my JDBC/Java based SQL client, which allows me to configure the number of decimals shown.
It uses a DecimalFormat to format the numbers returned from the JDBC driver.

When using the above example and configuring the client to show 4 decimals (which results in a format mask of "0.#" and
callingsetMaxDigits() with a value of 4) I will get: 

3
3.0000
3.0000
3.0000

Which is quite interesting as it seems that from the driver's point of view (or Java?) there is only a difference
betweenno decimal digits or some decimal digits.  It does not seem to get (or request) the information  about how many
decimalsthere were. 

This seems to be done upon retrieving, because when inserting the above example data (again with or without quotes)
fromJava, the display in psql's display is the same as if the data had been inserted from psql. 

Thomas




В списке pgsql-jdbc по дате отправления:

Предыдущее
От: dmp
Дата:
Сообщение: Re: Mapping Java BigDecimal
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: Mapping Java BigDecimal