On Jul 18, 2007, at 16:01 , Michael Glaesemann wrote:
CREATE OR REPLACE FUNCTION one_when(BOOLEAN)
RETURNS INTEGER
LANGUAGE SQL as $_$SELECT value_when($1,1)$_$;
I forgot to add that you can cast booleans to integers, so one_when
(expr) is equivalent to expr::int:
# SELECT (true and false)::int, (true or false)::int;
int4 | int4
------+------
0 | 1
(1 row)
Of course, this rewriting shouldn't affect the performance at all: it
should just make it easier for you to read, which does have some value.
Michael Glaesemann
grzm seespotcode net