tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment
Share this page:

Oracle/PLSQL: ORA-04091

Learn the cause and how to resolve the ORA-04091 error message in Oracle.

Description

When you encounter an ORA-04091 error, the following error message will appear:

  • ORA-04091: table name is mutating, trigger/function may not see it

Cause

A statement executed a trigger or custom PL/SQL function. That trigger/function tried to modify or query a table that is currently being modified by the statement that fired the trigger/function.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Re-write the trigger/function so that it does not try to modify/query the table in question.

For example, if you've created a trigger against the table called orders and then the trigger performed a SELECT against the orders table as follows:

CREATE OR REPLACE TRIGGER orders_after_insert
AFTER INSERT
   ON orders
   FOR EACH ROW

DECLARE
   v_quantity number;

BEGIN
   SELECT quantity
   INTO v_quantity
   FROM orders
   WHERE order_id = 1;

END;

You would receive an error message as follows:

Oracle PLSQL

When you create a trigger against a table, you can't modify/query that table until the trigger/function has completed.

Remember that you can always use the :NEW and :OLD values within the trigger, depending on the type of trigger. Learn more about Triggers.