Re: Constraint that compares and limits field values

Поиск
Список
Период
Сортировка
От MargaretGillon@chromalloy.com
Тема Re: Constraint that compares and limits field values
Дата
Msg-id OF5B4B2DFF.DA8A60CE-ON88257101.006744DD-88257101.0066E896@CHROMALLOY.COM
обсуждение исходный текст
Ответ на Re: Constraint that compares and limits field values  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: Constraint that compares and limits field values  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general

>Michael Fuhr <mike@fuhr.org> wrote on 01/25/2006 10:25:38 AM:
> In 8.1, and in earlier versions if you create a cast from boolean
> to integer, you could do this:
>
> ALTER TABLE event
> ADD CONSTRAINT two_nulls_1 CHECK (
> (evenid1 IS NOT NULL)::int +
> (evevid1 IS NOT NULL)::int +
> (evreid1 IS NOT NULL)::int = 1);
>
> This works because the cast converts true to 1 and false to 0;
> you're adding up the number of true expressions and requiring that
> the sum equal 1 (i.e., that exactly one expression be true).
>
> --
> Michael Fuhr

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.

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Margaret Gillon, IS Dept., Chromalloy Los Angeles, ext. 297

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

Предыдущее
От: Philippe Ferreira
Дата:
Сообщение: Re: My very first PL/pgSQL procedure...
Следующее
От: Patrick Hatcher
Дата:
Сообщение: Trigger question: ROW or STATEMENT?