Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: to_char number format with optional decimal-point?
Martin T. wrote:
> G Quesnel wrote:
> > I don't have the answer to your question, but if you can not find the
> > formating string then you could produce the desired result by adding a
> > case structure around your to_char formatting. Something like ...
> > <snip>
> > Hopefully, someone else can come up with a formating string.
>
> Thanks for your tip! Seems a pretty clean solution.
>
> Let me state something that may spark some more response ;) ...
>
> 1.) It is *not* possible with the ORACLE to_char function (in version
> 9i2) to specify a number format model that will reproduce the default
> behaviour of the function w/o format model.
> 2.) It is, specifically, *not* possible to describe a number format
> model such that the decimal-point is not displayed if there are no
> decimals and is displayed if there are significant decimals.
>
1 = wrong
2 = wrong
:-)
So ... finally stumbled upon the default format (why do the docs not state this? grml ...)
Default format for to_char seems to be 'TM9'
"proove" :) ...
declare
v_num NUMBER:= 0;
begin
LOOP
v_num := v_num + 0.1;
dbms_output.put_line('Num: ' || to_char(v_num) || ' ... explicit: '
|| to_char(v_num, 'TM9'));
EXIT WHEN v_num > 2;
END LOOP;
end;
see also
http://forums.oracle.com/forums/thread.jspa?messageID=714945򮣁
best,
Martin
Received on Tue Aug 08 2006 - 05:00:15 CDT