Friday, February 24, 2017

Decimal & number Confusion

SQL> create table detail
  2  (id varchar2(1), QTY NUMBER(10,2));
Table created.

memorize: (10-2)=8 digit must be then (dot.) fraction more insert but forms not insert more then 2 digit and sql plus show 2 digits


SQL> insert into detail values('1',55555555555555.444);
insert into detail values('1',55555555555555.444)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',55555555.444);

1 row created.

SQL> insert into detail values('1',5555555555.444);
insert into detail values('1',5555555555.444)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',5555555555.44);
insert into detail values('1',5555555555.44)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',5555555555.4);
insert into detail values('1',5555555555.4)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',555555555.4);
insert into detail values('1',555555555.4)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',55555555.4);

1 row created.

SQL> insert into detail values('1',555555555.4);
insert into detail values('1',555555555.4)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',55555555.44);

1 row created.

SQL> insert into detail values('1',55555555.444);

1 row created.

SQL> insert into detail values('1',55555555.4444);

1 row created.

SQL> insert into detail values('1',55555555.444444);

1 row created.

SQL> insert into detail values('1',55555555.444444444);

1 row created.

SQL> insert into detail values('1',55555555.4444444444444444444444444444444444444444444444444444

1 row created.

SQL> select * from detail
  2  ;

I        QTY
- ----------
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4

8 rows selected.

SQL> insert into detail values('1',55555555.456);

1 row created.

SQL> select * from detail;

I        QTY
- ----------
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.5

9 rows selected.

SQL> insert into detail values('1',55555555.056);

1 row created.

SQL> select * from detail;

I        QTY
- ----------
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.5
1 55555555.1

10 rows selected.

SQL> insert into detail values('1',55555555.406);

1 row created.

SQL> select * from detail;

I        QTY
- ----------
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.4
1 55555555.5
1 55555555.1
1 55555555.4

11 rows selected.
Different  
SQL> alter table detail  modify qty number(10,5);
alter table detail  modify qty number(10,5)
                           *
ERROR at line 1:
ORA-01440: column to be modified must be empty to decrease precision or scale


SQL> truncate table detail;

Table truncated.

SQL> select * from detail;

no rows selected

SQL> alter table detail  modify qty number(10.5);
alter table detail  modify qty number(10.5)
                                      *
ERROR at line 1:
ORA-02017: integer value required


SQL> alter table detail  modify qty number(10,5);

Table altered.

SQL> desc detail
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 VARCHAR2(1)
 QTY                                                NUMBER(10,5)


memorize: (10-5)=5 digit must be then (dot.) fraction more insert
 SQL> insert into detail values('1',55555555.406);
insert into detail values('1',55555555.406)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',55555.40);

1 row created.

SQL> insert into detail values('1',555555.40);
insert into detail values('1',555555.40)
                              *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into detail values('1',55555.4585858585858558585);

1 row created.

No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...