Oracle中的触发器

创建触发器的语法:

Create trigger 触发器的名字
after insert/update/delete/(select是没有触发器的)
on 表名字
declare

begin

dbms_output.put_line("使用触发器打印一句话");


end;
/

语法明细:

CREATE [or REPLACE] TRIGGER 触发器的名字

{BEFORE | AFTER}

{DELETE| UPDATE | INSERT}

ON 表名

{FOR EACH ROW (WHERE条件)}

PL/SQL块

触发器创建完毕,在插入数据的时候出现如下错误:

在行: 12 上开始执行命令时出错 -
insert into emp(empno,ename,sal,deptno) values(1001,'Jack',50000,10)
错误位于命令行: 12 列: 13
错误报告 -
SQL 错误: ORA-04098: 触发器 'SCOTT.SAYNEWEMP' 无效且未通过重新验证
04098. 00000 -  "trigger '%s.%s' is invalid and failed re-validation"
*Cause:    A trigger was attempted to be retrieved for execution and was
           found to be invalid.  This also means that compilation/authorization
           failed for the trigger.
*Action:   Options are to resolve the compilation/authorization errors,
           disable the trigger, or drop the trigger.

问题解决参考文章:http://xuehu2009.iteye.com/blog/445403

原文地址:https://www.cnblogs.com/blogofwyl/p/4854175.html