CREATE trigger [dbo].[TRI_INSTEAD]
on [VIEW]
instead of Update
ASdeclare @old_content nvarchar(50)
declare @content nvarchar(50)
declare @help_id nvarchar(10)
declare @student_id nvarchar(10)
if update([民族])
begin
select @old_content = [民族] from deleted
select @student_id = [学生编号] from deleted
select @content = [民族] from inserted
SELECT @help_id = [编号] FROM [HELP_民族]
where [民族] = @content if (@help_id = NULL)
begin
raiserror('要求的不在HELP库里',10,0)
ROLLBACK
return
end update [在校生基本信息表]
set [在校生基本信息表].[民族] = @help_id
where [在校生基本信息表].[学生编号] = @student_id
end
怎么回事??????其中的ROLLBACK没用错吧
on [VIEW]
instead of Update
ASdeclare @old_content nvarchar(50)
declare @content nvarchar(50)
declare @help_id nvarchar(10)
declare @student_id nvarchar(10)
if update([民族])
begin
select @old_content = [民族] from deleted
select @student_id = [学生编号] from deleted
select @content = [民族] from inserted
SELECT @help_id = [编号] FROM [HELP_民族]
where [民族] = @content if (@help_id = NULL)
begin
raiserror('要求的不在HELP库里',10,0)
ROLLBACK
return
end update [在校生基本信息表]
set [在校生基本信息表].[民族] = @help_id
where [在校生基本信息表].[学生编号] = @student_id
end
怎么回事??????其中的ROLLBACK没用错吧
-->
if (@help_id is NULL)用ado调用时,会把
update view_name set col=1 where id=1自动转化成:
update basetable_name set col=1 where id=1
造成没有调用触发器。