CREATE TRIGGER Dele_Pers_Code
ON A001
instead of delete
AS
begin
begin tran
declare @tablename varchar(4)
declare table_cursor cursor for
SELECT Table_physical FROM x_control_table WHERE (X_kinds_id = 'X') AND (Table_id <> 50) AND (Table_id <> 1)
open table_cursor
fetch next from table_cursor into @tablename
while @@fetch_status=0
begin
exec(' delete from '+@tablename+' where pers_code in (select pers_code from deleted) ')
FETCH NEXT FROM table_cursor into @tablename
end
close table_cursor
DEALLOCATE table_cursor
if @@error!=0
rollback tran
else commit tran
end
触发器报错:deleted对象找不到,什么原因?
ON A001
instead of delete
AS
begin
begin tran
declare @tablename varchar(4)
declare table_cursor cursor for
SELECT Table_physical FROM x_control_table WHERE (X_kinds_id = 'X') AND (Table_id <> 50) AND (Table_id <> 1)
open table_cursor
fetch next from table_cursor into @tablename
while @@fetch_status=0
begin
exec(' delete from '+@tablename+' where pers_code in (select pers_code from deleted) ')
FETCH NEXT FROM table_cursor into @tablename
end
close table_cursor
DEALLOCATE table_cursor
if @@error!=0
rollback tran
else commit tran
end
触发器报错:deleted对象找不到,什么原因?
解决方案 »
- 如何截取字符串?
- 整型数据能不能转换成字符型数据?
- 关于用P2P实现文件下载
- 如何读取ftp服务器上某一个目录下所有的文件名(在线等)
- 如何把tStringList里存的字符串分开(在线)
- 请问如何在treeview对象上设置底图,就像flashget 1.3那样?
- dll问题:下面的dll编译没有问题,为何运行时会发生异常?同样的函数在exe文件中运行正常。
- 求救??????
- help!!
- 有关dbgrid的一系列问题
- 高分请教:OleVariant赋值问题
- 用TAdoDataSet如何使用单字匹配符过滤数据,就像是Filter:='MyField like ''MyVal_%''' 一样,但好像不行,它不能把_当作一个单字匹配符
INSTEAD OF DELETE triggers can be defined on a view or table to replace the standard action of the DELETE statement. Usually, the INSTEAD OF DELETE trigger is defined on a view to modify data in one or more base tables.DELETE statements do not specify modifications to existing data values. DELETE statements specify only the rows that are to be deleted. The inserted table passed to a DELETE trigger is always empty. The deleted table sent to a DELETE trigger contains an image of the rows as they existed before the UPDATE statement was issued. In the case of an INSTEAD OF DELETE trigger on a view or table, the format of the deleted table is based on the format of the select list defined for the view
不用Exec也可以
但怎么将@tablename作为一个表名参数呢