Oracle中利用Trigger进行工作
来源:互联网 发布:淘宝衣服质量 编辑:程序博客网 时间:2024/06/13 06:00
Oracle数据库中,有些情况下,对数据记录需要记录日志,或保存操作历史等情况.在此我们可以借助“数据库Trigger”进行。下面以一例进行说明:
CREATE OR REPLACE TRIGGER aits_auth_group_auth_trga_diu
AFTER update OR DELETE OR INSERT on aits_authority_group_auth
for each row
/*****************************************************************************************
*
* Trigger Name : aits_auth_group_auth_trga_diu
* Description : Log insert, Modify ,delete action to History table
* Version : 1.0
*****************************************************************************************/
declare
BEGIN
IF inserting THEN
INSERT INTO aits_auth_group_auth_history
(application_code, auth_id, ranage_code,
group_code, module_code, function_code,
creation_date, created_by, last_update_date,
last_updated_by, action_type)
VALUES
(:new.application_code, :new.auth_id, :new.ranage_code,
:new.group_code, :new.module_code, :new.function_code,
:new.creation_date, :new.created_by, :new.last_update_date,
:new.last_updated_by, aits_pak_common.InsertDesc);
ELSIF DELETING THEN
INSERT INTO aits_auth_group_auth_history
(application_code, auth_id, ranage_code,
group_code, module_code, function_code,
creation_date, created_by, last_update_date,
last_updated_by, action_type)
VALUES
(:OLD.application_code, :OLD.auth_id, :OLD.ranage_code,
:OLD.group_code, :OLD.module_code, :OLD.function_code,
:OLD.creation_date, :OLD.created_by, :OLD.last_update_date,
:OLD.last_updated_by, aits_pak_common.DeleteDesc);
ELSIF UPDATING THEN
IF UPDATING('application_code') OR UPDATING('auth_id') OR UPDATING('ranage_code')
OR UPDATING('group_code') OR UPDATING('module_code') OR UPDATING('function_code') THEN
INSERT INTO aits_auth_group_auth_history
(application_code, auth_id, ranage_code,
group_code, module_code, function_code,
creation_date, created_by, last_update_date,
last_updated_by, action_type)
VALUES
(:new.application_code, :new.auth_id, :new.ranage_code,
:new.group_code, :new.module_code, :new.function_code,
:new.creation_date, :new.created_by, :new.last_update_date,
:new.last_updated_by, aits_pak_common.UpdateDesc);
END IF;
END IF;
end aits_auth_group_auth_trga_diu;
- Oracle中利用Trigger进行工作
- oracle中利用trigger,sequence自动生成ID
- Oracle中Trigger例子1
- Oracle中Trigger例子2
- trigger oracle
- Oracle Trigger
- Oracle Trigger
- Oracle Trigger
- Oracle Trigger
- ORACLE TRIGGER
- Oracle Trigger
- Oracle-trigger
- Oracle Trigger
- oracle trigger
- oracle trigger
- oracle trigger
- oracle中利用rownum进行分页的问题
- Oracle中利用undo进行数据的恢复操作
- xinit启动X Window System过程初探
- Option Explicit 的作用
- HTML与FLASH的静态传值(Flash 传值)
- stdafx.h头文件的作用
- C专家编程学习笔记——第三章(三):有效地解读C语言的声明
- Oracle中利用Trigger进行工作
- 微软最新发布104个专业级的Web标准测试代码
- 静态链接库(Lib)与动态链接库(DLL)的区别
- Mplayer Codec ID
- repeater 分页
- 从Jboss4.0.2迁移到Jboss5.1.0
- 矩形显示
- 行列转换及存储过程分页
- Spring+Hibernate