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

x
?
Solved

Updating a NUMBER datatype with a decimal value in Oracle

Posted on 2014-10-22
3
Medium Priority
?
2,340 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
What we learned in Webroot's webinar on multi-vector protection.
This video shows how to recover a database from a user managed backup
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

704 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