帮同事看了一个触发器引起的错误,他应项目组需求改项目报错,出现问题显示ORA-04098触发器无效且未通过重新验证。
发现他们使用navicat开发工具,打开触发器在定义一栏显示
BEGIN
<<COLUMN_SEQUENCES>>
BEGIN
IF INSERTING AND :NEW.ID IS NULL THEN
SELECT T_YW_USER_TERNIMAL_ACCOUNT_SEQ.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
END IF;
END COLUMN_SEQUENCES;
END;
CREATE OR REPLACE TRIGGER "DCMANAGEMENT"."T_YW_USER_TERNIMAL_ACCOUNT_TRG" BEFORE INSERT ON "DCMANAGEMENT"."T_YW_USER_TERNIMAL_ACCOUNT" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW ENABLE
BEGIN
<<COLUMN_SEQUENCES>>
BEGIN
NULL;
END COLUMN_SEQUENCES;
END;
因为我不会使用navicat创建触发器。所以根据触发器提供的信息重写了触发器,用命令创建
CREATE OR REPLACE TRIGGER "DCMANAGEMENT"."T_YW_USER_TERNIMAL_ACCOUNT_TRG"
BEFORE INSERT ON "DCMANAGEMENT"."T_YW_USER_TERNIMAL_ACCOUNT" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW ENABLE
BEGIN
IF INSERTING AND :NEW.ID IS NULL THEN
SELECT T_YW_USER_TERNIMAL_ACCOUNT_SEQ.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
END IF;END;
因为查到有人说navicat对于最后的end有换行bug,所以提到上面一行,重新执行问题解决。