Constraint that compares and limits field values

Поиск
Список
Период
Сортировка
От MargaretGillon@chromalloy.com
Тема Constraint that compares and limits field values
Дата
Msg-id OF37DD51B2.024C7F1A-ON88257100.0060BCB2-88257100.00618341@CHROMALLOY.COM
обсуждение исходный текст
Ответы Re: Constraint that compares and limits field values  (Richard Huxton <dev@archonet.com>)
Список pgsql-general

I have a table that I am using to hold keys for M:M relationships.   I have six fields that can hold the keys and I do this because I validate the key with a foreign key constraint. Fields evevid1, evevid2 hold keys from the event table, evreid1, evreid2 hold keys from the resource table, etc. The 0 works with the FK constraints because in each table being referenced I have a record with id = 0 that is empty.  Each row should only have two foreign key values and the other key field values are 0.

How do I put a constraint on the Insert / Update to make sure that only two fields out of the six have a value > 0 in them.

I want to make sure that one of these three fields has a value > 0 and the other two are 0.
 evevid1 int4
 evenid1 int4
 evreid1 int4

Same here. I want to make sure that one of these three fields has a value > 0 and the other two are 0.
 evevid2 int4
 evenid2 int4
 evreid2 int4
 
Please reply to me as well as the list because I get the digest version and it might take a while to get the reply there.

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

This e-mail message and any attachment(s) are for the sole use of the intended recipient(s) and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient(s), please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachment(s) to the original message.

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

Предыдущее
От: "Brian A. Seklecki"
Дата:
Сообщение: Re: Backup and Restore mechanism in Postgres
Следующее
От: Thomas Hallgren
Дата:
Сообщение: Re: user defined function