From: | MargaretGillon(at)chromalloy(dot)com |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | Richard Huxton <dev(at)archonet(dot)com>, MargaretGillon(at)chromalloy(dot)com, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Constraint that compares and limits field values |
Date: | 2006-01-25 17:55:58 |
Message-ID: | OF29912CB7.903685C8-ON88257101.0061CC62-88257101.0061D59A@CHROMALLOY.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>Michael Fuhr wrote:
> 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.
You are correct, in each group of three columns, one needs to have an
integer and the other two need to be NULL. So I need to modify the
constraint to be....
ALTER TABLE event
ADD CONSTRAINT two_nulls_1 CHECK
((evenid1 IS NULL) AND (evevid1 IS NULL) and (evreid1 IS NOT NULL)) OR
((evenid1 IS NULL) AND (evevid1 IS NOT NULL) and (evreid1 IS NULL)) OR
((evenid1 IS NOT NULL) AND (evevid1 IS NULL) and (evreid1 IS NULL))
Correct?
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*** ***
Margaret Gillon, IS Dept., Chromalloy Los Angeles, ext. 297
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Buttafuoco | 2006-01-25 17:58:44 | Re: My very first PL/pgSQL procedure... |
Previous Message | Bruce Momjian | 2006-01-25 17:54:22 | Re: [GENERAL] Different exponent in error messages |