Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 739
  • Last Modified:

numbers in oracle

(oracle8i, solaris2.7)
I want to have a money field in my table. So it means I always want the numbers there to have two digits after the point, even if it's 5.00.
How do I do that?
0
wabby26
Asked:
wabby26
  • 2
  • 2
1 Solution
 
Mark GeerlingsDatabase AdministratorCommented:
You cannot force Oracle to store non-significant digits in a number column.  If you really think there is value in storing non-significant zeroes, you will have to define the column as varchar2 and do conversions.  It seems much easier to let Oracle store the data in its native, most efficient way, and format the output (in SQL*Plus or whatever client tool you use) in whatever format you wish.
0
 
wabby26Author Commented:
OK, so if I leave it to be a number, and do the translation while using the select command, isn't there any function that can take that number and put it in that format (money format)?
0
 
Mark GeerlingsDatabase AdministratorCommented:
You have multiple options.

You could set up a view that does a to_char conversion on the number column(s) then do your select from the view rather than table.

Or, you could set up a function (named to_money for example) then apply that function to the column(s) in your select statements.

In SQL*Plus you can set the column characteristics to the format you want like:
column [column name] format 999,999.99

The view may be the best approach for you, but I don't know what client or fron-end tool you are using - that may influence your options.
0
 
wabby26Author Commented:
10x
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now