日期:2014-05-19  浏览次数:20482 次

为什么这个触发器不会循环??

create   table   tabA   (sid   varchar(20),sname   varchar(20))

insert   into   taba   values( 'P00001 ', 'ling ')
insert   into   taba   values( 'P00002 ', 'wang ')
insert   into   taba   values( 'P00005 ', 'dong ')
insert   into   taba   values( 'SY0009 ', 'stud ')


create   table   tabB   (sid   varchar(20),payfor   dec(14,2)   default   0)


create   trigger   tri_tabb
      on   tabb
      for   insert  
as
    set   nocount   on
      delete   tabb   from   inserted   a,tabb   b   where   a.sid=b.sid   --and   a.sid   not   in   (select   sid   from   taba)

        insert   into   tabb   (sid)   select   sid   from   taba     where   sid   not   in(select   sid   from   tabb)

--测试
insert   into   tabb   values( 'P000010 ', '1500 ')


select   *   from   tabb

---为什么这个触发器不会循环??

------解决方案--------------------
为社么会循环,当taba中所有的sid都插入表tabb中时就结束了啊。
------解决方案--------------------
不会吧,尽管操作吧。
------解决方案--------------------
楼主说的循环是什么意思?触发器中看不到循环啊?
------解决方案--------------------
楼主问的是为什么没有级联触发。