Re: Casting to varchar - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: Casting to varchar
Date
Msg-id 463B9A9F.80008@iol.ie
Whole thread Raw
In response to Casting to varchar  (Scott Ribe <scott_ribe@killerbytes.com>)
Responses Re: Casting to varchar
List pgsql-general
On 04/05/2007 21:34, Scott Ribe wrote:

> Just discovered (the hard way) that casting a boolean column ::varchar
> doesn't work. I assume I can add a function somewhere that will define a
> default cast for this? Are there any other standard types that can't be cast

I just use something like this:

create or replace function bool2str(TheValue boolean)
returns varchar as
$$
begin
   if TheValue then
     return 'true';
   else
     return 'false';
   end if;
end;
$$
language plpgsql stable;

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Casting to varchar
Next
From: Alvaro Herrera
Date:
Subject: Re: Casting to varchar