简体   繁体   中英

how to fix oracle ORA-01722 invalid number error

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.

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 ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM