关于触发器的问题?初学请多多指教,可加分之200分
/*
用途:保证在修改主代表时(即Other_Identity=‘1’)随从信息能够及时更新
*/
CREATE TRIGGER [TRIG_D_Forum_Representative_other] ON dbo.D_Forum_Representative
FOR INSERT, UPDATE
AS
Begin
IF UPDATE(Organization_Chi)
Update D_Forum_Representative Set
Organization_Chi = Organization_Chi
Where Main_Representative_ID=Representative_ID and other_identity<>'1'
意思当某一行Organization_Chi被修改时,
所有的Main_Representative_ID等于该修改行Representative_ID 值且other_identity<>'1'的Organization_Chi值都被修改为Organization_Chi
另外一个问题
删除是的触发器问题
当删除行other_identity = '1',则删除所有Main_Representative_ID=Representative_ID(该删除行值) 的值
when (other_identity = '1') then
delete from D_Forum_Representative
where Main_Representative_ID=Representative_ID
else when (other_identity <> '1')
update D_Forum_Representative
set
where Main_Representative_ID=Representative_ID and
(其它行值)Representative_ID <>Representative_ID (该行值)