Solved

Updating a NUMBER datatype with a decimal value in Oracle

Posted on 2014-10-22
3
1,712 Views
Last Modified: 2014-10-23
How do I update a datatype NUMBER with a decimal value?

UPDATE myTable SET myNumberVal=0.07

Open in new window


and

UPDATE myTable SET myNumberVal='0.07'

Open in new window


both result in the value being updated as "0"
0
Comment
Question by:Mike Miller
[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
3 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40397833
The first one is correct.  If you cannot see the decimal places it is one of two issues:
The table does not allow decimal places or what you are using to query it isn't showing them.

Post the results of:
desc myTable ;


If the column is a whole number like number(10), then you cannot store decimals.

It would need to be defined as something like number(12,2).
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40398138
Here it is in action:
SQL> drop table tab1 purge;

Table dropped.

SQL> create table tab1(col1 number);

Table created.

SQL>
SQL> insert into tab1 values(.07);

1 row created.

SQL> select * from tab1;

      COL1
----------
       .07

SQL> rollback;

Rollback complete.

SQL>
SQL> alter table tab1 modify col1 number(10);

Table altered.

SQL> insert into tab1 values(.07);

1 row created.

SQL> select * from tab1;

      COL1
----------
         0

SQL> rollback;

Rollback complete.

SQL>
SQL> alter table tab1 modify col1 number(12,2);

Table altered.

SQL> insert into tab1 values(.07);

1 row created.

SQL> select * from tab1;

      COL1
----------
       .07

Open in new window

0
 

Author Closing Comment

by:Mike Miller
ID: 40399420
That's what it was. I copied this table from another server and the precision/scale didn't copy over with it. Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

751 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