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!

How to rpad after decimal point?

unknown-879931Aug 27 2014 — edited Sep 1 2014

Hi All,

I want all numbers have 2 zeros after decimal point like below.

14 ==> 14.00

4.6 ==> 4.60

2.4 ==> 2.40

5.45 ==> 5.45

However, at the sametime it shouldbe NUMBER, not CHAR. I am trying to use the following formula. However it doesn't work.

select to_number(to_char(4.2, '99D99')) from dual; ==>  4,2  (The result should be 4.20 instead of 4.2)

select to_number(to_char(4.2, '99.99')) from dual; ==> ORA-01722: ERROR


So what should I do?

Thanks in advance.

This post has been answered by Frank Kulash on Aug 27 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 29 2014
Added on Aug 27 2014
7 comments
1,915 views