Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NUMBER Data type's Negative Scale

715303Sep 29 2009 — edited Sep 29 2009
This is what I read in the 1z0-051 Study Guide:
The NUMBER data type may optionally be qualified with a precision and a scale. The precision sets the maximum number of digits in the number, and the scale is how many of those digits are to the right of the decimal point. If the scale is negative, this has the effect of replacing the last digits of any number inserted with zeros, which do not count toward the number of digits specified for the precision. If the number of digits exceeds the precision, there will be an error; if it is within the precision but outside the scale, the number will be rounded (up or down) to the nearest value within the scale.
I am not sure if I understood this paragraph the correct way or not and hence this query:

I created this table t1
create table t1 
(col1 number,
col2 number(4),
col3 number(4,2),
col4 number(4,-2));
INSERT INTO T1 (COL4) VALUES (1234); = 1200 is inserted
INSERT INTO T1 (COL4) VALUES (12.34); = 0 is inserted
INSERT INTO T1 (COL4) VALUES (12345.34); = 12300 is inserted. Should is not throw an error as the whole value should be of length 4 (including the precision). 
However, INSERT INTO T1 (COL4) VALUES (123456789.34); throws error.
How is this working? Please help!

Edited by: TuX4EvA on Sep 29, 2009 4:12 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2009
Added on Sep 29 2009
2 comments
10,021 views