Switching NULL status
Posted in 2000
Topics: General Discussion
Hi All, Question, Is there a way to set up, if (on the same table) column1 is null than column2 must have a value and if column2 is null then column1 must have a value? Would I use a constraint? If so, how might I go about this. If not, any suggestions. Thanks in advance. Marco Sent via Deja.com http://www.deja.com/ Before you buy.
<mdelerme@my-deja.com> wrote in message news:8li6fg$624$1@nnrp1.deja.com...
> Hi All,
>
>
> Question, Is there a way to set up, if (on the same table) column1 is
> null than column2 must have a value and if column2 is null then column1
> must have a value? Would I use a constraint? If so, how might I go
> about this. If not, any suggestions. Thanks in advance.
>
create table a
( c1 integer, c2 integer);
alter table a add constraint
check ((c1 is null and c2 is not null) or (c1 is not null and c2 is null))constraint ck_switching_null;
Regards,
Roman Zarzecki
rzarzecki@gis.com.pl