From: Karel Zak <zakkr@zf.jcu.cz>
To: Ludwig Lim <lud_nowhere_man@yahoo.com>
Cc: Frank Joerdens <frank@joerdens.de>
Cc: PostgreSQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: to_char and '=' weirdness
Date: Thu, 8 Aug 2002 14:11:55 +0200
Message-ID: <20020808141154.C14021@zf.jcu.cz> (raw)
In-Reply-To: <20020808114824.4497.qmail@web40018.mail.yahoo.com>
References: <20020808133300.A15630@superfly.archi-me-des.de>
<20020808114824.4497.qmail@web40018.mail.yahoo.com>
On Thu, Aug 08, 2002 at 04:48:24AM -0700, Ludwig Lim wrote:
>
> > which would appear to indicate that to_char actually
> > yields the string
> > '04109'. Why doesn't the '=' operator work then?
>
> I tried running a test sql statement
> select(length(to_char(99,'00000')))
> It return six.
>
> I think that postgreSQL put a leading blank to
> indicate that it is a positive number (not sure, just
> my opinion)
Right.
> try using :
>
> select to_char(plz,'00000')
> from andresses
> where trim(to_char(plz,'00000'))='04109'
use FM instead trim(): to_char(plz,'FM00000')
...and please, better read docs :-)
Karel
--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: zakkr@zf.jcu.cz, lud_nowhere_man@yahoo.com, frank@joerdens.de
Subject: Re: to_char and '=' weirdness
In-Reply-To: <20020808141154.C14021@zf.jcu.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox