how to fix oracle ORA-01722 invalid number error

21,145

If you have a numeric column, all you have to do is use a to_char with the right parameters; this should do the work:

select to_char(column1, '00000000000000000D000000', 'NLS_NUMERIC_CHARACTERS = ''.,''') from ...
Share:
21,145

Related videos on Youtube

Pronto
Author by

Pronto

Updated on July 09, 2022

Comments

  • Pronto
    Pronto almost 2 years

    I have Oracle db with these inputs on column1(NUMBER(22,6)) in myTable.

    0
    199935,15
    1026299
    

    I want to display these columns like that:

    00000000000000000.000000
    00000000000199935.150000
    00000000001026299.000000
    

    My query:

    SELECT trim(to_char(trim(replace(column1,',','.')),'9999999999999990.999999')) 
    FROM myTable;
    

    But Oracle shows this error. How can I fix?

    01722. 00000 -  "invalid number"
    *Cause:    The specified number was invalid.
    *Action:   Specify a valid number.
    
    • Aleksej
      Aleksej about 5 years
      What is the type of your column? Is it a number or a string?
    • Pronto
      Pronto about 5 years
      column1 type is NUMBER(22,6). Thanks