From: | "Shoaib Mir" <shoaibmir(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Brian Hurt" <bhurt(at)janestcapital(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: cannot cast type boolean to text? |
Date: | 2007-06-14 18:43:32 |
Message-ID: | bf54be870706141143m7939f764sb829da2a14e038bd@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
This should help:
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;
--
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)
On 6/14/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Brian Hurt <bhurt(at)janestcapital(dot)com> writes:
> > SELECT true :: text;
> > ERROR: cannot cast type boolean to text
>
> > I was wondering why this is so.
>
> Because there's no pg_cast entry for this conversion.
>
> There will be one in 8.3, but for older releases make your own with
> CREATE CAST.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
From | Date | Subject | |
---|---|---|---|
Next Message | nhrcommu | 2007-06-15 13:43:12 | Formatting function, simple Q |
Previous Message | Shoaib Mir | 2007-06-14 18:41:10 | Re: cannot cast type boolean to text? |