简体   繁体   中英

NLS_NUMERIC_CHARACTERS in Oracle's to_char() function

I'm trying to convert numeric field to varchar.

select value from nls_session_parameters
where parameter = 'NLS_NUMERIC_CHARACTERS'

returns ','

code is:

select to_char(sm.trxn_amount, '999999999999D000', 'NLS_NUMERIC_CHARACTERS = '',.''')

sm.trxn_amount format is NUMBER(18,3)

for example, lets run this code

select sm.trxn_amount
from x

result is 106729,000

if i then run

select 
to_char('106729,000', '999999999999D000', 'NLS_NUMERIC_CHARACTERS = '',.''')
from dual

result is

106729,000

but if i run

select to_char(sm.trxn_amount, '999999999999D000', 'NLS_NUMERIC_CHARACTERS = '',.''')

result is

106729.000

what am i missing? cant get decimal point to be ','

If that column's datatype is NUMBER , then it most probably doesn't have trailing zeros (behind the decimal point).

Anyway, it seems that everything is fine on my 11g:

SQL> create table sm (trxn_amount number(18, 3));

Table created.

SQL> insert into sm values (106729);

1 row created.

SQL> select * from sm;

TRXN_AMOUNT
-----------
     106729

SQL> select to_char(sm.trxn_amount, '999999999999D000', 'NLS_NUMERIC_CHARACTERS = '',.''') result from sm;

RESULT
-----------------
       106729,000

SQL>

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