'set null' in foreign key constraint

'set null' in foreign key constraint

Post by Lene Smid » Thu, 04 Oct 2001 22:46:13



Is this constraint with set null possible or do I need a trigger?

alter table TGAkt
  add constraint TGLrer_TGAkt_FK1
          foreign key (Lrer_OID) references TKPerson (OID)
          on delete set null
          on update cascade)

 
 
 

'set null' in foreign key constraint

Post by Dejan Sark » Thu, 04 Oct 2001 23:11:26


Lene,

Set Null and Set Default actions are not supported in SQL 2000 constraints,
so yes, you need a trigger here.

--
Dejan Sarka, SQL Server MVP
FAQ from Neil & others at: http://www.sqlserverfaq.com
Please reply only to the newsgroups.


Quote:> Is this constraint with set null possible or do I need a trigger?

> alter table TGAkt
>   add constraint TGLrer_TGAkt_FK1
>           foreign key (Lrer_OID) references TKPerson (OID)
>           on delete set null
>           on update cascade)


 
 
 

'set null' in foreign key constraint

Post by PPS » Thu, 04 Oct 2001 23:26:05


You can use either "Cascade" or "NoAction" keywords with "On Delete".

So you will need a trigger to "set null".


Quote:> Is this constraint with set null possible or do I need a trigger?

> alter table TGAkt
>   add constraint TGLrer_TGAkt_FK1
>           foreign key (Lrer_OID) references TKPerson (OID)
>           on delete set null
>           on update cascade)