Re: [PATCHES] to_char(FM9.9) bug fix

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] to_char(FM9.9) bug fix
Date: 2002-09-23 07:10:24
Message-ID: 20020923091024.B7293@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Fri, Sep 20, 2002 at 09:24:00PM +0200, Peter Eisentraut wrote:
> Karel Zak writes:
>
> > test=# select to_char(0,'FM9.9');
> > to_char
> > ---------
> > 0.
> > (1 row)
> >
> > test=# select to_char(1,'FM9.9');
> > to_char
> > ---------
> > 1.
> > (1 row)
>
> I find this highly bizzare. The FM modifier means to omit unnecessary

In the code it's commented as "terrible Ora format" :-)

> trailing stuff. There is no reasonable business or scientific custom to
> leave a trailing point after a number.

I think so. I don't know who can use format number like '1.' or '.0'.
Can somebody explain why Oracle implement it, who use it?

> Or perhaps a more pragmatic question is, how would I print a number
> without the trailing point?

Don't use FM or use FM9.0

Examples:

'SVRMGR' = Oracle8 Release 8.0.5.0.0
'test=#' = PostgreSQL 7.3b1

test=# select to_char(1, 'FM9.9');
to_char
---------
1.

SVRMGR> select to_char(1, 'FM9.9') from dual;
TO_C
----
1.

test=# select to_char(1, '9.9');
to_char
---------
1.0

SVRMGR> select to_char(1, '9.9') from dual;
TO_C
----
1.0

test=# select to_char(1, 'FM9.0');
to_char
---------
1.0

SVRMGR> select to_char(1, 'FM9.0') from dual;
TO_C
----
1.0

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2002-09-23 08:06:21 Re: DROP COLUMN misbehaviour with multiple inheritance
Previous Message Karel Zak 2002-09-23 06:39:34 Re: regression test failure in CVS HEAD

Browse pgsql-patches by date

  From Date Subject
Next Message Stephan Szabo 2002-09-23 07:51:32 Re: Implementation of LIMIT on DELETE and UPDATE statements
Previous Message Yury Bokhoncovich 2002-09-23 06:18:30 Re: Implementation of LIMIT on DELETE and UPDATE statements