Re: boolean to int
От | Pavel Stehule |
---|---|
Тема | Re: boolean to int |
Дата | |
Msg-id | Pine.LNX.4.44.0403151957590.26812-100000@kix.fsv.cvut.cz обсуждение исходный текст |
Ответ на | boolean to int (Mage <mage@mage.hu>) |
Ответы |
Re: boolean to int
Re: boolean to int |
Список | pgsql-general |
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 >
В списке pgsql-general по дате отправления: