Home » RDBMS Server » Server Administration » Storing a number with exactly two decimal places
Storing a number with exactly two decimal places [message #373395] Fri, 13 April 2001 13:23 Go to next message
tedagem
Messages: 3
Registered: April 2001
Junior Member
Hello, I need to store a numeric value so that there are always two decimal places. E.g. "31" gets stored as "31.00".

How do I set up my create table statement to ensure that all inserted values are in the correct format?
Re: Storing a number with exactly two decimal places [message #373397 is a reply to message #373395] Fri, 13 April 2001 15:42 Go to previous message
Robert Moy
Messages: 15
Registered: December 2000
Junior Member
Hello:

You can use this code:

1 create table mywage2 (
2 salary float,
3* name varchar2(20))
SQL> run
1 create table mywage2 (
2 salary float,
3* name varchar2(20))

SQL> insert into mywage2
2 values(4000.00,'Bob');

1 row created.

SQL> insert into mywage2
2 values(5000.01,'Mary');

1 row created.

SQL> select * from mywage2;

SALARY NAME
--------- --------------------
4000 Bob
5000.01 Mary

If you use ".00" it will not show however anything other than zero it will show.

If you need anymore help, please send back a respond
Previous Topic: decode command
Next Topic: Storing a number with exactly two decimal places
Goto Forum:
  


Current Time: Mon Dec 23 09:45:37 CST 2024