10.2.0.2.0: Use of TO_NUMBER with nls independent decimal separator .
217564Aug 6 2008 — edited Aug 19 2009I have a varchar2 column that may contain number values formatted as strings using a locale independent format. The decimal separator is always "." regardless of the locale. I would like to sort rows with number values in numeric order in the database.
Say I have the following rows in the mytable:
value
5.5
-9.9
1001.1
And NLS_LANG = FRENCH_FRANCE.UTF8
I tried doing something like the following:
select *
from mytable
order by to_number(value, 'TM', 'NLS_NUMERIC_CHARACTERS = ''.,'' ')
I used the number format 'TM' because I want the text minimum format. The numeric strings do not have thousandths separators. Unfortunately, I get ORA-01722: invalid number. The 'TM' format does not work with to_number. It only works with to_char. Although this is not documented, I found other people have run into the same problem.
I'd prefer not to have to specify a number format that covers any number value than can be stored by in a double. Are there any suggestions?