Hello, you can use own cast.

create or replace function int2bool (integer) returns boolean as '
  select case when $1=1 then ''t''::boolean else ''f''::boolean end;
' language sql;

create or replace function bool2int (boolean) returns integer as '
  select case when $1 then 0 else 1 end; ' language sql;

create cast (integer as boolean) with function int2bool(integer) 
  as implicit;

create cast (boolean as integer) with function bool2int(boolean)
  as implicit;

regards
Pavel Stehule


On Mon, 15 Mar 2004, Mage wrote:

>        Hello,
> 
> I'm wondering why pgsql doesn't support boolean typecasts like select 
> true::int;
> Many client applications including php assign 1 to true and 0 to false
> 
> I see no use of pgsql boolean type with php, I use int2 or integer.
> 
>        Mage
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to