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!

to_char clarification

User_LCHKLNov 28 2014 — edited Nov 30 2014

1)I have a table with data as mentioned below

Table Tn (n number(6,3));

SQL> insert into tn values( 123.123) ;

1 row created.

SQL> insert into tn values(0) ;

1 row created.

SQL>insert into tn values(0.123)

1 row created.

Excepted o/p is mentioned below.

n

--------

123.123

000.000

000.123

when i check in google and i found the solution as mentioned below

select to_char(n,'000.000') from t;

can anyone explain above query.I have gone through the format specifiers but still not clear

2)Why the o/p is same in both cases?

select    TO_CHAR(9999999.67,'0000000D00')   from dual;

select    TO_CHAR(9999999.67,'9999999D99')   from dual;

I am posting this query after reading format specifiers for numbers?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2014
Added on Nov 28 2014
5 comments
596 views