Reputation: 349
I am facing a to_char()
currency formatting problem here.
The below code is working for me:
SELECT TO_CHAR(10000,'L99G999D99MI',
'NLS_NUMERIC_CHARACTERS = ''.,''
NLS_CURRENCY = $') "Amount"
FROM DUAL;
which will provide me with the output: $10,000.00
.
Now, I want to convert the currency into a France currency, which the desire output is 10 000,00
or a Switzerland currency with output 10'000.00
. So, I modified the code as shown below for both of the case above:
SELECT TO_CHAR(10000,'L99G999D99MI',
'NLS_NUMERIC_CHARACTERS = ''"", ""''
NLS_CURRENCY = ''$'' ') "Amount"
FROM DUAL;
SELECT TO_CHAR(10000,'L99G999D99MI',
'NLS_NUMERIC_CHARACTERS = ''". "''
NLS_CURRENCY = ''$'' ') "Amount"
FROM DUAL;
But this code does not work and showing an error of ORA-12702
. Is there any problem with the code?
Upvotes: 6
Views: 63189
Reputation: 61
This can be used as well since the decimal notation is already know for French countries
SELECT TO_CHAR(1000000000,'999,999,999,999.99') "Amount" FROM DUAL;
Upvotes: 6
Reputation: 2218
If you want to do it in the query:
SELECT TO_CHAR(10000,'L99G999D99MI',
'NLS_NUMERIC_CHARACTERS = ''.''''''
NLS_CURRENCY = ''$'' ') "Amount"
FROM DUAL;
Gives $10'000.00
(as this string is getting pre-processed there are pairs of quotes around the characters (becoming single) and then to get a single-quote in the string you need four quotes to become one!)
SELECT TO_CHAR(10000,'L99G999D99MI',
'NLS_NUMERIC_CHARACTERS = '', ''
NLS_CURRENCY = ''$'' ') "Amount"
FROM DUAL;
Gives $10 000,00
Upvotes: 9
Reputation: 27251
As one of the options, you can set NLS_TERRITORY
parameter at a session level:
alter session set nls_territory='FRANCE';
select to_char(10000, 'fm99G999D00') as french
from dual;
Result:
FRENCH
----------
10 000,00
alter session set nls_territory='SWITZERLAND';
select to_char(10000, 'fm99G999D00') as switzerland
from dual
Result:
SWITZERLAND
-----------
10'000.00
Upvotes: 2