Re: Constraint to ensure value does NOT exist in another table? - Mailing list pgsql-general

From Mike Christensen
Subject Re: Constraint to ensure value does NOT exist in another table?
Date
Msg-id BANLkTi=Ys4mRchmLk7nGf3=-0ww+h5J2_A@mail.gmail.com
Whole thread Raw
In response to Re: Constraint to ensure value does NOT exist in another table?  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-general
>> I know I can setup a FK constraint to make sure Table1.ColA exists in
>> Table2.Key, however what if I want to do the reverse?
>>
>> I want to ensure Table1.ColA does NOT exist in Table2.Key..  Can I do
>> this with any sort of CHECK constraint, trigger, custom function, etc?
>
>
> The most common constraints are provided for, but then after that you
> have to use triggers.
>
> PostgreSQL deliberately doesn't support queries in CHECK constraints
> for this reason.

Thanks!  I wrote a Trigger for this and it seems to work fairly well..
 I kinda figured that was the obvious way, but thought there might be
some new 9.x feature that made this sort of thing possible.

pgsql-general by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Symbols and versioning of binary releases; running a symbol server
Next
From: salah jubeh
Date:
Subject: order by and view def.