视图中加了触发器,但是delphi程序中执行更新时,却没有执行触发器?
vw_CheckGroup 为视图,触发器如下:create trigger tri_vw_checkGroup_update
on  vw_CheckGroup
instead of  update
as
begin
  insert into mylog
    select ctg_Name,getdate() from inserted  
end
go

解决方案 »

  1.   

    create trigger tri_vw_checkGroup_update
    on  vw_CheckGroup
    instead of  update//不能用for update吗?
    as
    begin
      insert into mylog
        select ctg_Name,getdate() from inserted  
    end
    go
      

  2.   

    create trigger tri_vw_checkGroup_update
    on  vw_CheckGroup
    for  update -- 改为for,如无特别要求的话
      

  3.   

    最好如楼上所说的那样.
    另外
    instead of  update
    可判断更新的是哪列.是不是如FOR那样,我记不清了.
      

  4.   

    instead of  update 
    //
    insert 
    or
     update
      

  5.   

    简单测试了下,没有问题
    ---创建表
    create table t(id int primary key ,a int, b int)
    go
    --插入数据
    insert into t select 1,2,3
    union select 2,3,4
    go
    create view v_t
    as
     select * from t
    go
    select * from v_t
    go
    --创建触发器
    create TRIGGER tr_v_t ON v_t
    instead of update
    as
    begin
      if (select id from inserted where id =1)>0 
      update v_t set a=a+1 where id=2
    end
    go
    update v_t set a= 8 where id=1
    select * from v_t
    go
    drop trigger tr_v_t
    drop table t
    drop view v_t
    go
      

  6.   

    在Sql的查询分析器上没有问题,但是用Delphi数据集控件打开这个视图,然后调用Insert.
    结果发现还是没有调用触发器?