On Wed, Jan 25, 2006 at 10:51:23AM -0800, MargaretGillon@chromalloy.com wrote:
> I am in version 7.3 and it will not let me cast, I get message "ERROR:
> Cannot cast type boolean to integer". I will save this for when I upgrade.
You can create casts with CREATE CAST.
http://www.postgresql.org/docs/7.3/static/sql-createcast.html
Something like this should work:
CREATE FUNCTION bool2int(boolean) RETURNS integer AS '
SELECT CASE WHEN $1 THEN 1 ELSE 0 END;
' LANGUAGE sql IMMUTABLE STRICT;
CREATE CAST (boolean AS integer) WITH FUNCTION bool2int(boolean);
--
Michael Fuhr