Search Postgresql Archives

Re: Constraint that compares and limits field values

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

 



On Wed, Jan 25, 2006 at 08:39:00AM -0800, MargaretGillon@xxxxxxxxxxxxxx wrote:
> I have taken your suggestion and changed the values to NULL for the empty 
> foreign keys. Thank you for the constraint. I modified it to check for 
> NULL and it works great. 
> 
> ALTER TABLE event
>  ADD CONSTRAINT two_nulls_1 CHECK (((((evenid1 IS NULL) AND (evevid1 IS 
> NULL)) OR ((evevid1 IS NULL) AND (evreid1 IS NULL))) OR ((evenid1 IS NULL) 
> AND (evreid1 IS NULL))));

Is there a requirement that exactly one column be NOT NULL?  If so
then you'll need to add a check for that because this constraint
would allow all three to be NULL.

-- 
Michael Fuhr


[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