Oracle 23.26PL/SQLLab-verified · 2026-11-29

ORA-04088: error during execution of trigger

A trigger failed; the actual error is the first line of the stack, and ORA-06512 shows the trigger line.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-04088: error during execution of trigger 'LAB_A.TRG_ORDERS_GRADE'

Jump to a cause

  1. 01SELECT INTO in the trigger finds no row (ORA-01403)
  2. 02The trigger rejects the data on purpose (ORA-20001)
  3. 03The trigger writes to a log table whose column is too small (ORA-12899)

Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim

ORA-04088 never comes alone. It is the last line of a stack: the first line is the real error, ORA-06512: at "LAB_A.TRIGGER_NAME", line N points to the line inside the trigger, and ORA-04088 only tells you that a trigger was running. The INSERT or UPDATE you ran may be perfectly fine.

In the three runs below the first line was ORA-01403, ORA-20001 and ORA-12899. Each was fixed where that first error came from: the trigger code, the input data, or the log table.

01SELECT INTO in the trigger finds no row (ORA-01403)

A BEFORE INSERT trigger copies the customer's grade with SELECT grade INTO :NEW.grade FROM customers WHERE customer_id = :NEW.customer_id. Inserting an order for customer 2, who is not in customers, gave ORA-01403: no data found, ORA-06512 at TRG_ORDERS_GRADE line 2, then ORA-04088.

After adding EXCEPTION WHEN NO_DATA_FOUND THEN :NEW.grade := 'NONE'; to the trigger, the same INSERT worked and the row got grade NONE.

Setup
Setuprun as lab_a
CREATE TABLE customers (customer_id NUMBER PRIMARY KEY, grade VARCHAR2(10));
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, customer_id NUMBER, amount NUMBER, grade VARCHAR2(10));
INSERT INTO customers VALUES (1, 'GOLD');
COMMIT;
CREATE OR REPLACE TRIGGER trg_orders_grade
BEFORE INSERT ON orders
FOR EACH ROW
BEGIN
  SELECT grade INTO :NEW.grade FROM customers WHERE customer_id = :NEW.customer_id;
END;
/
OUTPUT
Table created.


Table created.


1 row created.


Commit complete.


Trigger created.
Reproducerun as lab_a
INSERT INTO orders (order_id, customer_id, amount) VALUES (100, 2, 5000);
✕ ERROR
INSERT INTO orders (order_id, customer_id, amount) VALUES (100, 2, 5000)
            *
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "LAB_A.TRG_ORDERS_GRADE", line 2
ORA-04088: error during execution of trigger 'LAB_A.TRG_ORDERS_GRADE'
Help: https://docs.oracle.com/error-help/db/ora-01403/
Checkrun as lab_a
SELECT customer_id, grade FROM customers WHERE customer_id = 2;
OUTPUT
no rows selected
Fixrun as lab_a
CREATE OR REPLACE TRIGGER trg_orders_grade
BEFORE INSERT ON orders
FOR EACH ROW
BEGIN
  SELECT grade INTO :NEW.grade FROM customers WHERE customer_id = :NEW.customer_id;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    :NEW.grade := 'NONE';
END;
/
OUTPUT
Trigger created.

Whether a missing customer should be allowed is a business decision. If not, add the customer first instead of catching the exception.

After the fixrun as lab_a
INSERT INTO orders (order_id, customer_id, amount) VALUES (100, 2, 5000);
SELECT order_id, customer_id, grade FROM orders;
✓ SUCCESS
1 row created.


  ORDER_ID CUSTOMER_ID GRADE
---------- ----------- ----------
       100           2 NONE

1 row selected.

02The trigger rejects the data on purpose (ORA-20001)

The trigger raises RAISE_APPLICATION_ERROR(-20001, 'amount must be positive: ' || :NEW.amount) when amount <= 0. INSERT INTO orders VALUES (1, -500, 'NEW') returned ORA-20001: amount must be positive: -500, then ORA-06512 and ORA-04088.

Here the trigger is doing its job. Reading the trigger source from user_source showed the rule, and inserting amount 500 succeeded.

Setup
Setuprun as lab_a
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, amount NUMBER, status VARCHAR2(10));
CREATE OR REPLACE TRIGGER trg_orders_check
BEFORE INSERT OR UPDATE ON orders
FOR EACH ROW
BEGIN
  IF :NEW.amount <= 0 THEN
    RAISE_APPLICATION_ERROR(-20001, 'amount must be positive: ' || :NEW.amount);
  END IF;
END;
/
OUTPUT
Table created.


Trigger created.
Reproducerun as lab_a
INSERT INTO orders VALUES (1, -500, 'NEW');
✕ ERROR
INSERT INTO orders VALUES (1, -500, 'NEW')
            *
ERROR at line 1:
ORA-20001: amount must be positive: -500
ORA-06512: at "LAB_A.TRG_ORDERS_CHECK", line 3
ORA-04088: error during execution of trigger 'LAB_A.TRG_ORDERS_CHECK'
Checkrun as lab_a
SELECT text FROM user_source WHERE name = 'TRG_ORDERS_CHECK' ORDER BY line;
OUTPUT
TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TRIGGER trg_orders_check
BEFORE INSERT OR UPDATE ON orders
FOR EACH ROW
BEGIN
  IF :NEW.amount <= 0 THEN
    RAISE_APPLICATION_ERROR(-20001, 'amount must be positive: ' || :NEW.amount);
  END IF;
END;

8 rows selected.
After the fixrun as lab_a
INSERT INTO orders VALUES (1, 500, 'NEW');
✓ SUCCESS
1 row created.

03The trigger writes to a log table whose column is too small (ORA-12899)

An AFTER UPDATE trigger writes old and new status to orders_log. orders.status is VARCHAR2(20) but orders_log.new_status is VARCHAR2(10). Updating status to 'PARTIALLY_SHIPPED' (17 characters) gave ORA-12899 for ORDERS_LOG.NEW_STATUS (actual: 17, maximum: 10), then ORA-06512 and ORA-04088.

The error names the log table, not the table you updated. After ALTER TABLE orders_log MODIFY (old_status VARCHAR2(20), new_status VARCHAR2(20)) the UPDATE worked and the log row was written.

Setup
Setuprun as lab_a
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, status VARCHAR2(20));
CREATE TABLE orders_log (order_id NUMBER, old_status VARCHAR2(10), new_status VARCHAR2(10), changed_at DATE);
INSERT INTO orders VALUES (1, 'NEW');
COMMIT;
CREATE OR REPLACE TRIGGER trg_orders_log
AFTER UPDATE OF status ON orders
FOR EACH ROW
BEGIN
  INSERT INTO orders_log VALUES (:OLD.order_id, :OLD.status, :NEW.status, SYSDATE);
END;
/
OUTPUT
Table created.


Table created.


1 row created.


Commit complete.


Trigger created.
Reproducerun as lab_a
UPDATE orders SET status = 'PARTIALLY_SHIPPED' WHERE order_id = 1;
✕ ERROR
UPDATE orders SET status = 'PARTIALLY_SHIPPED' WHERE order_id = 1
       *
ERROR at line 1:
ORA-12899: value too large for column "LAB_A"."ORDERS_LOG"."NEW_STATUS" (actual: 17, maximum: 10)
ORA-06512: at "LAB_A.TRG_ORDERS_LOG", line 2
ORA-04088: error during execution of trigger 'LAB_A.TRG_ORDERS_LOG'
Help: https://docs.oracle.com/error-help/db/ora-12899/
Checkrun as lab_a
SELECT table_name, column_name, data_length FROM user_tab_columns WHERE column_name LIKE '%STATUS' ORDER BY table_name, column_name;
OUTPUT
TABLE_NAME                     COLUMN_NAME                    DATA_LENGTH
------------------------------ ------------------------------ -----------
ORDERS                         STATUS                                  20
ORDERS_LOG                     NEW_STATUS                              10
ORDERS_LOG                     OLD_STATUS                              10

3 rows selected.
Fixrun as lab_a
ALTER TABLE orders_log MODIFY (old_status VARCHAR2(20), new_status VARCHAR2(20));
OUTPUT
Table altered.
After the fixrun as lab_a
UPDATE orders SET status = 'PARTIALLY_SHIPPED' WHERE order_id = 1;
SELECT order_id, old_status, new_status FROM orders_log;
✓ SUCCESS
1 row updated.


  ORDER_ID OLD_STATUS           NEW_STATUS
---------- -------------------- --------------------
         1 NEW                  PARTIALLY_SHIPPED

1 row selected.

FAQ

How do I fix ORA-04088?

Fix the first error in the stack, not ORA-04088 itself. Above, that meant handling NO_DATA_FOUND in the trigger, sending a positive amount, or widening the log table column.

How do I find which line of the trigger failed?

Read the ORA-06512 line: it shows the trigger name and line number, for example at "LAB_A.TRG_ORDERS_GRADE", line 2.

My UPDATE doesn't touch orders_log. Why does ORA-12899 mention it?

A trigger on the table you updated inserted into orders_log, and that insert failed. ORA-04088 shows which trigger did it.

What does ORA-20001 with ORA-04088 mean?

ORA-20000 to ORA-20999 are errors raised by code with RAISE_APPLICATION_ERROR. The message text is the rule the trigger checks; change the data to satisfy it.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0