繁体   English   中英

PL/SQL:什么是错误:ORA-04082:表级触发器中不允许新或旧引用

[英]PL/SQL: What is ERROR: ORA-04082: NEW or OLD references not allowed in table level triggers

您好,我在执行 pl/sql 触发器时遇到了一些问题。 我想做一个做“历史”的触发器。 我创建了一个表,使用以下代码记录触发器的输出:

create table control(
camp1 varchar2(255) 
);

它还没有工作,但我们很接近。 现在在用户:7623856 的帮助下,当我执行此操作时,会出现在此处输入图像描述我在 SQL 开发人员和 oracle 11 工作

这是新代码

create or replace trigger t_auditar_alta_empleat
after insert on empleats
for each row
begin
  if :new.codi_dept is null then 
  insert into control values('Alta empleat amb codi' || :new.codi_emp);
  else
  insert into control values('Alta empleat amb codi' || :new.codi_emp || 'amb el codi de departament '|| new:codi_dept);
  end if;
end;

并出现新的错误。

*LINE/COL 错误

5/3 PL/SQL:SQL 语句被忽略 5/109 PLS-00049:错误的绑定变量 'CODI_DEPT' 5/109 PL/SQL:ORA-00917:缺少逗号错误:comprobar log de compilador*

您几乎就在那里,但按照定义,您当前有一个语句级触发器,但您需要一个行级触发器。 这里

create or replace trigger t_auditar_alta_empleat
after insert on empleats
for each row        -- added 
begin
  if :new.codi_dept is null then 
  insert into control values('Alta empleat amb codi' || :new.codi_emp);
  else
  insert into control values('Alta empleat amb codi' || :new.codi_emp || 'amb el codi de departament '|| new:codi_dept);
  end if;
end;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM