I have a table with numbers stored as varchar2
with \'.\' as decimal separator (e.g. \'5.92843\').
I want to calculate with these numbers using \',\' as tha
You might try one of the following approaches (take them for an idea as I do not have a DB for trying it here):
1) Use TO_NUMBER without a format. According to Oracle docs it uses a dot for decimal separator then.
If your number contains group separators, then first remove these and convert then:
TO_NUMBER(TRANSLATE(number, ',''' ,''))
2) Generate the number format from your input:
select TO_NUMBER(n, TRANSLATE(n,' 1,234.567890',TO_CHAR(9999.9, '9G999D9')||'99999'))
from (select '9,876.54' as n from dual);
The latter translates all digits to 9, your group character (here: comma) and your decimal separator (here: dot) to those used by Oracle by default.