以下是本人在sql server下写的触发器,运行的很好,由于不会oracle的pl/sql,该不成oracle下的,好痛苦啊!!CREATE TRIGGER identical_insert ON ch_mon
instead of INSERT
AS
if @@rowcount=0 return
declare @tbl varchar(64),@recno bigint,@itype varchar(64),@otype varchar(64)
select @tbl=tbl,@recno=recno,@itype=type from inserted
if not exists(select 1 from ch_mon where recno=@recno and tbl=@tbl)
begin
insert into ch_mon select * from inserted
return
end
select @otype=type from ch_mon where recno=@recno and tbl=@tbl
if @otype='insert' and @itype='delete'
begin
delete from ch_mon where recno=@recno and tbl=@tbl
return
end
if @otype='update' and @itype='delete'
update ch_mon set type='delete'where recno=@recno and tbl=@tbl
go我知道instead触发器可以用raise_application_error(-2000,'form instead-of trigger')实现,
但是语句怎么写都得到“警告: 创建的触发器带有编译错误。”!!!
instead of INSERT
AS
if @@rowcount=0 return
declare @tbl varchar(64),@recno bigint,@itype varchar(64),@otype varchar(64)
select @tbl=tbl,@recno=recno,@itype=type from inserted
if not exists(select 1 from ch_mon where recno=@recno and tbl=@tbl)
begin
insert into ch_mon select * from inserted
return
end
select @otype=type from ch_mon where recno=@recno and tbl=@tbl
if @otype='insert' and @itype='delete'
begin
delete from ch_mon where recno=@recno and tbl=@tbl
return
end
if @otype='update' and @itype='delete'
update ch_mon set type='delete'where recno=@recno and tbl=@tbl
go我知道instead触发器可以用raise_application_error(-2000,'form instead-of trigger')实现,
但是语句怎么写都得到“警告: 创建的触发器带有编译错误。”!!!
解决方案 »
- REGEXP_SUBSTR 给我解释一下谢谢
- oracle 菜鸟,弱弱的问一句,sqlplusw里面怎么命令怎么转行?
- 关于where的一个问题
- ORACLE 触发器 代码
- 触发器删除数据问题
- 求《Oracle PL/SQL程序设计基础教程》电子书
- 从ORACLE导出数据到 SQL SERVER 时报错,请问这个错误是什么意思?
- 存储过程的问题!大家帮帮忙呀!急
- 我现在USERS表空间的状态为只读,哪位知道是什么原因?怎么把它修改为ONLINE?
- 8i 在 P4上如何装?在线等待,急,急,急,急,急,急,急,急,急,急!!!!
- 请教高手关于Oracle9i中手工指定索引无法生效的问题
- 如何把sqlsever 数据库移植到 oracle当中去
lz试试
BEFORE INSERT ON
,看看能不能达到这样的效果