Search code examples
sqloracle-databaseoracle-apexvarchar2

Error in my sql (varchar2)


I have the following error in all my tables where I am using varchar2

error ORA-01438: value larger than specified precision allowed for this column

although I have used characters less than the specified length

enter image description here

Note: I am using oracle apex


Solution

  • According to the screenshot, it is the DEP_ID that raises the error, not DEP_NAME. It seems that you wrongly defined that column in the table. This is what you did:

    SQL> create table test (dep_id number(1, 10));
    
    Table created.
    
    SQL> insert into test (dep_id) values (1);
    insert into test (dep_id) values (1)
                                      *
    ERROR at line 1:
    ORA-01438: value larger than specified precision allowed for this column
    
    
    SQL> insert into test (dep_id) values (0.0000000001);
    
    1 row created.
    
    SQL>
    

    In other words, you set precision to "1" (i.e. allow only one significant digit), while scale is set to "10" (which represents "decimal" digits).

    For your sake, in this case set DEP_ID NUMBER, without precision or scale.