Re: where'd the spaces come from - Mailing list pgsql-sql

From Richard Huxton
Subject Re: where'd the spaces come from
Date
Msg-id 01b001c11c00$3ae2bbc0$1001a8c0@archonet.com
Whole thread Raw
In response to Re: where'd the spaces come from  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-sql
From: "Bruce Momjian" <pgman@candle.pha.pa.us>

> > Hi Bruce,
> >
> > a fix for what?
> > If you're meaning the leading space, then the fix is in the followup
post
> > that I made to my original quiestion. i.e.
> >
> > psql -c "select to_char(12,'xFM000');"
> >  to_char
> > ---------
> >  x012
> > (1 row)
> >
> > The 'FM' removes the space.
>
> So the FM is the correct way to do this, right?  There is no bug?

Well - it's certainly *unexpected* behaviour isn't it?

It is documented though (Karel Zak's given plenty of examples too):

"FM suppresses leading zeroes or trailing blanks that would otherwise be
added to make the output of a pattern be fixed-width"

Some of the examples show the difference too:

to_char(12,'9990999.9')   => ' 0012.0'
to_char(12,'FM9990999.9') => '0012'

I think the issue is you look at to_char() and make assumptions if you're
not familiar with it. I *seem* to remember someone saying Oracle worked this
way.

- Richard Huxton




pgsql-sql by date:

Previous
From: Christopher Sawtell
Date:
Subject: Re: Activation of plsql
Next
From: Christopher Sawtell
Date:
Subject: Re: Knowing new item in table...