Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-30 · container image gvenzl/oracle-free:23-slim
A trigger without FOR EACH ROW runs once per statement, not once per row, so there is no single row for :NEW or :OLD to point to. Oracle rejects the CREATE TRIGGER itself with ORA-04082 and the trigger is not created. The * in the output points at the trigger name.
Below are two cases reproduced on Oracle 26ai Free. In both, adding FOR EACH ROW was the fix.
01BEFORE UPDATE trigger that sets :NEW columns, without FOR EACH ROW
The trigger was meant to fill updated_at and updated_by on every update with :NEW.updated_at := SYSDATE, but FOR EACH ROW was missing. CREATE OR REPLACE TRIGGER orders_bu failed with ORA-04082.
With FOR EACH ROW added after BEFORE UPDATE ON orders, the trigger was created. An UPDATE set amount to 200 and the trigger filled updated_by with LAB_A and set updated_at.
Setup
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, amount NUMBER, updated_at DATE, updated_by VARCHAR2(30));
INSERT INTO orders VALUES (1, 100, NULL, NULL);
COMMIT;Table created.
1 row created.
Commit complete.CREATE OR REPLACE TRIGGER orders_bu
BEFORE UPDATE ON orders
BEGIN
:NEW.updated_at := SYSDATE;
:NEW.updated_by := USER;
END;
/CREATE OR REPLACE TRIGGER orders_bu
*
ERROR at line 1:
ORA-04082: NEW or OLD references not allowed in table level triggers
Help: https://docs.oracle.com/error-help/db/ora-04082/CREATE OR REPLACE TRIGGER orders_bu
BEFORE UPDATE ON orders
FOR EACH ROW
BEGIN
:NEW.updated_at := SYSDATE;
:NEW.updated_by := USER;
END;
/Trigger created.Write FOR EACH ROW between ON <table> and BEGIN. If a WHEN clause is used, it also needs FOR EACH ROW.
UPDATE orders SET amount = 200 WHERE order_id = 1;
SELECT order_id, amount, updated_by, CASE WHEN updated_at IS NOT NULL THEN 'SET' END AS updated_at FROM orders;
ROLLBACK;1 row updated.
ORDER_ID AMOUNT UPDATED_BY UPD
---------- ---------- ------------------------------ ---
1 200 LAB_A SET
1 row selected.
Rollback complete.02AFTER DELETE log trigger using :OLD, without FOR EACH ROW
A trigger copied deleted rows into orders_deleted with :OLD.order_id and :OLD.amount, but it was written as a statement-level AFTER DELETE ON orders trigger. Creating it failed with ORA-04082.
After adding FOR EACH ROW, the trigger was created. Deleting order 1 wrote one row (1, 100, LAB_A) to orders_deleted.
Setup
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, amount NUMBER, updated_at DATE, updated_by VARCHAR2(30));
INSERT INTO orders VALUES (1, 100, NULL, NULL);
COMMIT;
CREATE TABLE orders_deleted (order_id NUMBER, amount NUMBER, deleted_by VARCHAR2(30));Table created.
1 row created.
Commit complete.
Table created.CREATE OR REPLACE TRIGGER orders_ad
AFTER DELETE ON orders
BEGIN
INSERT INTO orders_deleted VALUES (:OLD.order_id, :OLD.amount, USER);
END;
/CREATE OR REPLACE TRIGGER orders_ad
*
ERROR at line 1:
ORA-04082: NEW or OLD references not allowed in table level triggers
Help: https://docs.oracle.com/error-help/db/ora-04082/CREATE OR REPLACE TRIGGER orders_ad
AFTER DELETE ON orders
FOR EACH ROW
BEGIN
INSERT INTO orders_deleted VALUES (:OLD.order_id, :OLD.amount, USER);
END;
/Trigger created.DELETE FROM orders WHERE order_id = 1;
SELECT order_id, amount, deleted_by FROM orders_deleted;
ROLLBACK;1 row deleted.
ORDER_ID AMOUNT DELETED_BY
---------- ---------- ------------------------------
1 100 LAB_A
1 row selected.
Rollback complete.FAQ
What is a table level trigger in Oracle?
A trigger without FOR EACH ROW. It fires once per statement, even if the statement changes many rows or none, so :NEW and :OLD are not available.
How do I fix NEW or OLD references not allowed in table level triggers?
Add FOR EACH ROW to make it a row-level trigger. In both cases on this page that was enough for CREATE TRIGGER to succeed.
Is the trigger created when ORA-04082 occurs?
No. CREATE TRIGGER stops with ORA-04082 (it is not the "created with compilation errors" warning), so fix the code and run CREATE OR REPLACE TRIGGER again.
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