Re: text(bool), text(numeric) - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: text(bool), text(numeric)
Date
Msg-id Pine.LNX.4.30.0111281429110.636-100000@peter.localdomain
Whole thread Raw
In response to text(bool), text(numeric)  (Vicktor <vic@adv.ru>)
List pgsql-bugs
Vicktor writes:

>  Why not exists functions for convert any type to text?
>  I can't find text(bool), text(numeric) ...

Just because *some* mapping between data types exists it doesn't mean it's
the sound, well-defined, be-all-end-all.  For instance, one might think
that TRUE => 't' and FALSE => 'f' is a reasonable bool=>text conversion,
but the first person you'll run into will claim that 1 and 0 is better,
and the second person will say that the answer should be locale-dependent.
So instead of bothering with this you get to make your own choice with

    CASE WHEN value THEN 'value if true' ELSE 'value if false' END

The issues are similar with numeric=>text, but the to_char() family of
functions should be able to solve all your problems in this area.

--
Peter Eisentraut   peter_e@gmx.net

pgsql-bugs by date:

Previous
From: Vicktor
Date:
Subject: Re: text(bool), text(numeric)
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #524: Bad quoting of backslash in text arrays