触发器,就是触发一件事情的发生,可能在事前,事后,或者进行中
CREATE OR REPLACE TRIGGER AOLDEMO.trigger1
AFTER DELETE OR INSERT OR UPDATE
ON AOLDEMO.S_EMP
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
tmpVar NUMBER;
/******************************************************************************
NAME: trigger1
PURPOSE: REVISIONS:
Ver Date Author Description
--------- ---------- --------------- ------------------------------------
1.0 2005-10-10 1. Created this trigger. NOTES: Automatically available Auto Replace Keywords:
Object Name: trigger1
Sysdate: 2005-10-10
Date and Time: 2005-10-10, 15:38:14, and 2005-10-10 15:38:14
Username: (set in TOAD Options, Proc Templates)
Table Name: S_EMP (set in the "New PL/SQL Object" dialog)
Trigger Options: (set in the "New PL/SQL Object" dialog)
******************************************************************************/
BEGIN
tmpVar := 0; SELECT MySeq.NEXTVAL INTO tmpVar FROM dual;
:NEW.SequenceColumn := tmpVar;
:NEW.CreatedDate := SYSDATE;
:NEW.CreatedUser := USER; EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END trigger1;
CREATE OR REPLACE TRIGGER AOLDEMO.trigger1
AFTER DELETE OR INSERT OR UPDATE
ON AOLDEMO.S_EMP
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
tmpVar NUMBER;
/******************************************************************************
NAME: trigger1
PURPOSE: REVISIONS:
Ver Date Author Description
--------- ---------- --------------- ------------------------------------
1.0 2005-10-10 1. Created this trigger. NOTES: Automatically available Auto Replace Keywords:
Object Name: trigger1
Sysdate: 2005-10-10
Date and Time: 2005-10-10, 15:38:14, and 2005-10-10 15:38:14
Username: (set in TOAD Options, Proc Templates)
Table Name: S_EMP (set in the "New PL/SQL Object" dialog)
Trigger Options: (set in the "New PL/SQL Object" dialog)
******************************************************************************/
BEGIN
tmpVar := 0; SELECT MySeq.NEXTVAL INTO tmpVar FROM dual;
:NEW.SequenceColumn := tmpVar;
:NEW.CreatedDate := SYSDATE;
:NEW.CreatedUser := USER; EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END trigger1;
解决方案 »
- 请教大家我的物化视图为什么创建不成功
- 向Oracle导入海量文本数据
- pl/sql调试时遇到的一个问题
- linux下怎么导入从windows导出的oracle的dmp,用sql plus
- 请问oracle中raise是什么意思?为什么不用rollback?
- 100元人民币,求助!任务马上就到期了!着急呀!
- SQL查询效率的问题!
- 建表错误,帮忙~
- oracle 想锁定一行,为什么在sql plus中执行for update 就没有反应?在cmd中执行就可以执行,也可以锁住该行
- 求一个统计查询,多谢
- 请问能否在sunfire v240的机器上装oracle9i,最低配置多少?
- 为什么oracle 10g没有Oracle Enterprise Management Console?
Oracle Developer使用指南(中文)
Oracle 8i PL_SQL高级程序设计
PL_SQL用户指南与参考
PL_SQL高级设计