Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert a number to Char with decimal

Rosario VigilanteJan 5 2017 — edited Jan 5 2017

hello to al,

I have to convert a number in char with 2 decimal of 9 char including comma(or point not mind), but I get this result

DF3 is right against DF2 (It have a blank as first string char).

Where am I wrong?

DF3 is right!! (9 char length with 2 decimal

DF2 is wrong because 10 char lenght

SELECT   10094.16 as df1,

       TO_CHAR(NVL(10094.16 ,0),'000000.00') as df2,

substr (TO_CHAR(NVL(10094.16 ,0),'000000.00') ,2,10) AS DF3 ,

REPLACE (substr (TO_CHAR(NVL(10094.16 ,0),'000000.00') ,2,10),'.',',') AS DF4     FROM dual

or this

SELECT   10094.1 as df1,

       TO_CHAR(NVL(10094.1 ,0),'000000.00') as df2,

substr (TO_CHAR(NVL(10094.1 ,0),'000000.00') ,2,10) AS DF3 ,

REPLACE (substr (TO_CHAR(NVL(10094.1 ,0),'000000.00') ,2,10),'.',',') AS DF4    FROM dual

  

Thanks in advance for any help

Thanks in advance

This post has been answered by mathguy on Jan 5 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 2 2017
Added on Jan 5 2017
6 comments
689 views