tags:

views:

149

answers:

2

How to change comma with period and period with comma e.g. 1,50,000.25 to 1.50.000,25 in oracle

+2  A: 

use replace

you may want to do tihs in a 3-pass process

e.g. swap all ',' into a unique 'safe' character (like ~)

then

swap all '.' into ','

finally

swap all '~' into '.'

Randy
btw - i agree if it is currency, the locale settings should do the reformatting for you. - above is a generalized method.
Randy
Yeah i got answer
Atul
+4  A: 

For numerics these characters - the group separator and the decimal separator - are controlled by the NLS (Globalization) parameters. The defaults are defined by NLS_TERRITORY but we can override those with specific characters through the NLS_NUMERIC_CHARACTERS parameter:

SQL> var n number
SQL> exec :n := 1000000.123

PL/SQL procedure successfully completed.

SQL> select :n from dual
  2  /

         :N
-----------
1000000.123

SQL> select to_char(:n, '9G999G999D999') from dual
  2  /

TO_CHAR(:N,'9G
--------------
 1,000,000.123

SQL> alter session set nls_numeric_characters = ",."
  2  /

Session altered.

SQL> select to_char(:n, '9G999G999D999') from dual
  2  /

TO_CHAR(:N,'9G
--------------
 1.000.000,123

SQL>

The Globalization stuff is covered extensively in the documentation. Find out more.

APC