How to Fix ORA-04098: Trigger Is Invalid and Failed Re-Validation in Oracle

Find why a trigger is invalid in USER_ERRORS, fix it so statements on the table work again, or disable it until it is fixed.

ORA-04098 is raised when an INSERT, UPDATE, or DELETE fires a trigger that is invalid and does not compile. CREATE TRIGGER saves the trigger even when it has compile errors, and every statement on the table then fails until the trigger is fixed or disabled. The message names the trigger, but not the error; USER_ERRORS has the details.

Reproduce the Error

The trigger sets a column that does not exist:

Example:

create table demo_bookings (booking_id number primary key, seat varchar2(4),
                            changed_at date);
create or replace trigger demo_bookings_biu
before insert or update on demo_bookings
for each row
begin
  :new.updated_at := sysdate;                 -- the column is CHANGED_AT
end;
/
insert into demo_bookings (booking_id, seat) values (1, '12A');

Output:

Table DEMO_BOOKINGS created.

Trigger DEMO_BOOKINGS_BIU compiled

Errors for TRIGGER DEMO_BOOKINGS_BIU:

LINE/COL ERROR
-------- -----------------------------------------------------------
2/3      PLS-00049: bad bind variable 'NEW.UPDATED_AT'

Error starting at line : 10
In command -
insert into demo_bookings (booking_id, seat) values (1, '12A')
Error at Command Line : 10 Column : 13
Error report -
SQL Error: ORA-04098: trigger 'NIMBUS.DEMO_BOOKINGS_BIU' is invalid and failed
re-validation

The compile error, PLS-00049 bad bind variable, appears after CREATE; the INSERT then fails with ORA-04098.

Fix: Read the Errors and Correct the Trigger

Example:

select status from user_objects where object_name = 'DEMO_BOOKINGS_BIU';
select line, position, text from user_errors where name = 'DEMO_BOOKINGS_BIU' order by sequence;
create or replace trigger demo_bookings_biu
before insert or update on demo_bookings
for each row
begin
  :new.changed_at := sysdate;
end;
/
insert into demo_bookings (booking_id, seat) values (1, '12A');
select booking_id, seat, changed_at from demo_bookings;
rollback;

Output:

STATUS
__________
INVALID

   LINE    POSITION TEXT
_______ ___________ ________________________________________________
      2           3 PLS-00049: bad bind variable 'NEW.UPDATED_AT'

Trigger DEMO_BOOKINGS_BIU compiled

1 row inserted.

   BOOKING_ID SEAT    CHANGED_AT
_____________ _______ ______________
            1 12A     06-OCT-2026

Rollback complete.

Things to Know

  • When the trigger cannot be fixed at once, ALTER TRIGGER ... DISABLE lets statements on the table run again; the trigger's logic is then skipped.
  • Triggers also become invalid when objects they use change, for example a dropped table or package.
  • Logon and DDL triggers that are invalid can block users from connecting or running DDL; fix them as an administrator.

Related Guides

Conclusion

ORA-04098 means a trigger on the table is invalid. Read its errors in USER_ERRORS, fix and recreate it, or disable it until it is fixed so the table can be used again.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted