Solved

numbers in oracle

Posted on 2000-05-16
4
735 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 50 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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 …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Suggested Courses

627 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