Unix Technical Forum

Default numeric scale of zero in JDBC?

This is a discussion on Default numeric scale of zero in JDBC? within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, I have discovered that the jdbc driver apparently uses a default scale of zero decimal places for SQL ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:31 AM
Todd Shoemaker
 
Posts: n/a
Default Default numeric scale of zero in JDBC?

Hello,

I have discovered that the jdbc driver apparently uses a default scale of zero decimal places for SQL numeric operators, including the sum() aggregate operator. For example, this query:

select (1.5 + 2);

This returns 4 from jdbc, but it returns 3.5 when run from within PGAdmin. The only way I can coerce the value to return decimal places is to explicity cast the value to a numeric with scale:

select cast(1.5 + 2 as numeric(10,2)) as value

This returns 3.5.

Also, queries like "select sum(value) from table" returns a rounded value, even though the column 'value' is numeric(16,2). Is there a magic vmparam or setting to default the precision at the jdbc driver level? I am trying to run a large existing system on PostgreSQL and it is not feasible to hunt down all numeric operations in thousands of classes to explicitly cast them. Have others have encountered this issue?

Thanks,

-Todd






---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com