视图中加了触发器,但是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
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
on vw_CheckGroup
instead of update//不能用for update吗?
as
begin
insert into mylog
select ctg_Name,getdate() from inserted
end
go
on vw_CheckGroup
for update -- 改为for,如无特别要求的话
另外
instead of update
可判断更新的是哪列.是不是如FOR那样,我记不清了.
//
insert
or
update
---创建表
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
结果发现还是没有调用触发器?