Search Postgresql Archives

Constraint that compares and limits field values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux