Number precision in Oracle

Questions and answers regarding general SQL and backend databases

Number precision in Oracle

Postby joshua » Mon Oct 21, 2013 9:52 pm

We are having a bit of a weird issue with Servoy saving numbers to our Oracle 10g database.

In a lot of our oracle tables we have a number column for prices. These prices all have a precision of 2 decimal places.

In servoy we have a table view form that is referencing one of the oracle tables with the number column. When a user enters in a price into the column in servoy it is sometimes saved with a large amount of extra decimal place data. So far I cannot find a pattern which would indicate why this happens only sometimes.

Here is an example. In servoy a user enters 2.31 for a price. There is a method onDataChange() to save the information to the database after the number is entered. After the amount is typed and the database is checked it can be seen that the number now has a length of 40 characters in the database and looks like 2.31000000000000005329070518200751394

There is no math being done on the data. The field on the form is using the price column in the oracle database as its dataprovider. The format property for the field is #.00 and the saving to the database is being done by a simple databaseManager.saveData() call. In oracle the column has a type of "Number". In the servoy properties for the database column the type is Number with a length of 22.

I'm completely baffled. I can find no pattern as to what would cause some entries to have the extra decimals and some to be saved properly with only 2 digits after the decimal.

Any ideas?

Thanks!!
joshua
 
Posts: 10
Joined: Sat Apr 21, 2012 10:56 pm

Re: Number precision in Oracle

Postby david » Mon Oct 21, 2013 10:03 pm

Does your number column have precision and scale designators? If not, it's a float number type instead of a fixed-point number type. For money, you definitely want a fixed-point number along the lines of: column_name NUMBER (*, 2).
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 13 guests