Home » SQL & PL/SQL » SQL & PL/SQL » Leading zero and comma decimal separator (Oracle 11 G)
Leading zero and comma decimal separator [message #636615] Wed, 29 April 2015 03:08 Go to next message
sinpeak
Messages: 59
Registered: January 2011
Location: india
Member
Hi,

My client's oracle DB installation is such that the decimal separator is "," and "." is the separator for thousand and more.
E.g One Thousand euros and twenty 25 cents is :

1.000,25

In such a case they want a leading zero in all numbers between -1 and 1 (excluding ).
E.g. 25 cents should be displayed as : 0,25 . But Oracle defaults such a value to : ",25" and not "0,25".

So I used the following :

select to_char(col1,'90.99') from table1


and got the result :

 0.75
 0.50
 0.25


The decimal sign should be "," and not "."
I can obviously use a REPLACE in my PLSQL code ( to replace "." with "," ). But I do not want to make it specific to a certain DB setting of command and dot. Is there any generic way to handling this ?

Re: Leading zero and comma decimal separator [message #636616 is a reply to message #636615] Wed, 29 April 2015 03:29 Go to previous messageGo to next message
Littlefoot
Messages: 21825
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Try G (group) and D (decimal) for separators, such as
select to_char(col1, '999G990D00') from table1;
Re: Leading zero and comma decimal separator [message #636617 is a reply to message #636615] Wed, 29 April 2015 03:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68764
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

See Number Format Elements in SQL Reference.

Re: Leading zero and comma decimal separator [message #636641 is a reply to message #636617] Wed, 29 April 2015 10:28 Go to previous message
sinpeak
Messages: 59
Registered: January 2011
Location: india
Member
Thanks all. It worked.
Previous Topic: How do I pass a table name dynamically using execute immediate
Next Topic: When was a tablespace created?
Goto Forum:
  


Current Time: Thu Jul 31 16:32:58 CDT 2025