Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: CUSTOM data integrity constraint
>>There are two fields in a table which are of datatype varchar2.
Say Field1, Field2.
When Field1 is NON NULL, Field2 CAN'T be NULL.
How could i impose this as a constraint to one of the fields?
<<
>...
I think this is achievable with INSERT trigger.
--
Nandakumar
(N.Kumar_at_rocketmail.com)
<
Just use a check constraint on the table:
CHECK ((Field1 IS NULL AND Field2 IS NULL) OR (Field1 IS NOT NULL AND Field2 IS NOT NULL)
As an aside:
According to the ANSI/ISO standard, a NOT NULL integrity constraint is an example of a CHECK integrity constraint, where the condition is
CHECK (column_name IS NOT NULL)
Therefore, NOT NULL integrity constraints for a single column can, in practice, be written in two forms: using the NOT NULL constraint or a CHECK constraint. For ease of use, you should always choose to define NOT NULL integrity constraints instead of CHECK constraints with the "IS NOT NULL" condition.
Paul in VT Received on Tue Aug 24 1999 - 13:17:39 CDT