Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

numbers in oracle

Posted on 2000-05-16
4
Medium Priority
?
737 Views
Last Modified: 2012-05-12
(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
Comment
Question by:wabby26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 150 total points
ID: 2815048
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
 

Author Comment

by:wabby26
ID: 2818144
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
 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 2818346
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
 

Author Comment

by:wabby26
ID: 2819215
10x
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question