简体   繁体   English

触发器在Oracle SQL Developer上不起作用

[英]Triggers not working on Oracle SQL Developer

I am getting an issue with execution of triggers. 我在执行触发器时遇到问题。 I am providing below the code for 1 of the triggers. 我在下面的触发器中提供了代码之一。

create or replace
TRIGGER abc_tr01
  BEFORE INSERT
  ON tablename
  FOR EACH ROW

BEGIN
  UPDATE tablename
     SET dtCreatedDate = SYSDATE
     WHERE incidentid = ( SELECT :NEW.incidentid 
                            FROM DUAL  );
END;

This trigger is supposed to update 1 of the columns ( dtCreatedDate ) of the tablename table and stores SYSDATE in it before an insertion is carried out on that table. 这个触发应该更新的列(第1 dtCreatedDate所述的) tablename的表,并存储SYSDATE在它之前的插入是在该表中进行。

It is failing to update the dtCreatedDate field however. 但是,它无法更新dtCreatedDate字段。

I have checked that the trigger is enabled. 我检查了触发器是否已启用。 It is getting fired at the insertion time too. 插入时也会被触发。 I checked that by injecting a syntax error in the trigger code which was promptly detected. 我通过在触发代码中注入语法错误来进行检查,该错误立即被检测到。

I am using SQL Developer 3.0. 我正在使用SQL Developer 3.0。

Please help. 请帮忙。

No need for the UPDATE statement: 不需要UPDATE语句:

create or replace
TRIGGER abc_tr01
  BEFORE INSERT
  ON tablename
  FOR EACH ROW
BEGIN
  :new.dtCreatedDate := sysdate;
END;
/

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

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