2.对表A建触发器:
create or replace trigger trig_name
after update on tableA
for each row
begin
insert into tableB(id,name...) values(:old.id,:old.Name,.....);
end;
create or replace trigger trig_name
after update on tableA
for each row
begin
insert into tableB(id,name...) values(:old.id,:old.Name,.....);
end;
解决方案 »
- oracle 分区索引的问题
- 用sql语句实现查询出所有的每一门功课都大于75分的学生的信息?急
- 程序退出时(或者被强行退出),如何终止所有运行中的线程
- 请问%type和%rowtype在定义变量时有什么不同?
- PB+ORACLE开发的问题?如何将数组作为参数传入oracle存储过程
- 一个select问题
- 存储过程分页中如何支持排序?
- redhat9下装oracle817遇到难题,急!在线等,分不够再加
- 提问:关于svrmgel
- 求教 将游标保存在索引表中
- 请问ORA-00472 PMON process terminated with error的 错误怎么解决?
- 两个用户各有自己的表空间,现想用sql语句将a用户的aa表中的数据插入到b用户的bb表中,怎么作呢??
[Q]怎么捕获表上的DML语句(不包括select)语句)
[A]可以采用dml触发器,如
CREATE OR REPLACE TRIGGER tr_capt_sql
BEFORE DELETE OR INSERT OR UPDATE
ON manager.test
DECLARE
sql_text ora_name_list_t;
state_sql capt$sql.sql_text%TYPE;
BEGIN
FOR i IN 1..ora_sql_txt(sql_text) LOOP
state_sql := state_sql || sql_text(i);
END LOOP;
INSERT INTO capt$sql(login_user,capt_time,ip_address,audsid,owner,table_name,sql_text)
VALUES(ora_login_user,sysdate,sys_context('USERENV','IP_ADDRESS'),
userenv('SESSIONID'),'MANAGER','TEST',state_sql);
EXCEPTION
WHEN OTHERS THEN
sp_write_log('Capture DML Exception:'||SQLERRM);
END tr_capt_sql;
在创建以上触发器时要注意几点
1、必须创建一个capt$sql的表,用来记录ddl的记录
2、sp_write_log原本是一个写日志的过程,可以置换为自己的需要,如null跳过
3.用windows自带的任务管理器