Re: Mapping Java BigDecimal
От | Donald Fraser |
---|---|
Тема | Re: Mapping Java BigDecimal |
Дата | |
Msg-id | B3CF49FF1A8B405BB64E09E642B16B5E@DEVELOP1 обсуждение исходный текст |
Ответ на | Mapping Java BigDecimal (Jakub Bednář <jakub.bednar@b2bcentrum.cz>) |
Список | pgsql-jdbc |
Ok I finally see what you are getting at. However I personally think that PostgreSQL is more correct. In Oracle (excuse the format if this type-cast is not valid in Oracle - I've never used Oracle) SELECT '3'::number(6,2) 3 In PostgreSQL SELECT '3'::numeric(6,2); 3.00 In Java test = new BigDecimal("3").setScale(2); System.out.println(test.toPlainString()); 3.00 If you have set a scale in PostgreSQL you will always get that number of decimal points and therefore your result from the database will always be consistent and therefore predictable. I would not want a database that returned data in any other way, just my opinion of course. Donald ----- Original Message ----- From: "dmp" <danap@ttc-cmc.net> To: <pgsql-jdbc@postgresql.org> Sent: Wednesday, January 20, 2010 4:27 AM Subject: Re: [JDBC] Mapping Java BigDecimal >> I would like to disagree with the statement that PostgreSQL >> numeric is a real with rounding to the precision specified. > > > I concede my mis-statement. > >> Hi All, >> >> We decide add support PostgreSQL database (now supporting only Oracle >> database) to our product. >> >> In Oracle we mapping Java BigDecimal to number(19, 2), in PostgreSQL to >> numeric(19, 2). >> >> If I store to "BigDecimal column" number without decimal, e.g. "3", than >> Oracle JDBC driver return "3", but PostgreSQL JDBC driver return "3.00". >> >> Is there some way (mapping, server setup, jdbc driver setup,...) how >> reach return number without trailing zeroes on decimal position? >> >> I'm using JDBC4 PostgreSQL Driver (v. 8.4-701) and PostgreSQL v. 8.1.18 >> (default for CentoOS 5.3). >> Thank you all > > > Oracle NUMBER(19,2), (precision,scale) is just the same as NUMERIC(19,2), > but if do > > Oracle NUMBER(19,2) ----> PostgreSQL Numeric, no precision yields the > desired result > as Jakub has figured out and keeps whatever precision input. > > danap. > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc >
В списке pgsql-jdbc по дате отправления: