Infix Function?

Поиск
Список
Период
Сортировка
От Peter Fein
Тема Infix Function?
Дата
Msg-id 42BF1331.4040504@pobox.com
обсуждение исходный текст
Ответы Re: Infix Function?  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Infix Function?  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
Hi-

I've defined an XOR function as:


CREATE OR REPLACE FUNCTION xor(bool, bool)
  RETURNS bool AS
'SELECT ($1 OR $2) AND NOT ($1 AND $2);'
  LANGUAGE 'sql' IMMUTABLE STRICT;

Is there anyway to create an infix version of this?  I'd really like be
able to write (where a..d are some boolean conditions):

a XOR b XOR c XOR d

instead of:

xor(a, xor(b, xor(c, d)))

which gets a little hard to understand as it gets long, esp. when mixed
with AND & OR.

I know one can do this with user-defined operators, but adding a #
operator for booleans seems ugly.  I thought I saw a way to do this, but
now I can't find it in the manual... TIA.

--Pete

--
Peter Fein                 pfein@pobox.com                 773-575-0694

Basically, if you're not a utopianist, you're a schmuck. -J. Feldman

В списке pgsql-general по дате отправления:

Предыдущее
От: Teunis Peters
Дата:
Сообщение: MacOSX, fink, missing readline/readline.h
Следующее
От: Joe
Дата:
Сообщение: Re: Win32 users?