Re: Cast boolean to text - Mailing list pgsql-general

From Shoaib Mir
Subject Re: Cast boolean to text
Date
Msg-id bf54be870612072107x587204f8u1d86046dc4270556@mail.gmail.com
Whole thread Raw
In response to Re: Cast boolean to text  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
You can create a cast like this:
 
create or replace function bool_to_text (boolean)
    returns char
    strict
    language sql as '
    select case
        when $1 then \'t\'
        else \'f\'
        end;
    ';

create cast (boolean as char(1))
    with function bool_to_text(boolean)
    as implicit;
Thank you,
Shoaib

 
On 12/7/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Willy-Bas Loos" <willybas@gmail.com> writes:
> I've noticed that postgresql   8.1.0 can cast a boolean to text, but version
> 8.1.5 CAN'T.

Better check again --- there has never been a standard cast from bool to
text.  Sure you didn't install a custom one in your 8.1.0 database?

                       regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: Restore database from files (not dump files)?
Next
From: Ashish Karalkar
Date:
Subject: pg_log missing