Error-04091
Contents |
MySQL MariaDB PostgreSQL SQLite MS Office Excel Access Word Web Development HTML CSS Color Picker Languages C Language More ASCII Table Linux UNIX Java Clipart Techie Humor Advertisement Oracle Basics ALIASES AND ora-04091 table is mutating AND & OR BETWEEN COMPARISON OPERATORS DELETE DISTINCT EXISTS FROM GROUP BY HAVING ora-04091 solution IN INSERT INSERT ALL INTERSECT IS NOT NULL IS NULL JOIN LIKE MINUS NOT OR ORDER BY PIVOT REGEXP_LIKE SELECT
Mutating Trigger In Oracle 10g With Example
SUBQUERY TRUNCATE UNION UNION ALL UPDATE WHERE Oracle Advanced Oracle Cursors Oracle Exception Handling Oracle Foreign Keys Oracle Loops/Conditionals Oracle Transactions Oracle Triggers String/Char Functions Numeric/Math Functions Date/Time Functions Conversion Functions Analytic Functions
Oracle Compound Trigger
Advanced Functions Oracle / PLSQL: ORA-04091 Error Message 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 oracle statement level trigger 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: 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. Share this page: Advertisement Back to top Home | About Us | Contact Us | Testimonials | Donate While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy. We use advertisements to support this website and fund the development of new content. Copyright © 2003-2016 TechOnTheNet.com. All rights reserved.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Ora-04091 After Insert Trigger
of this site About Us Learn more about Stack Overflow the company mutating trigger in oracle 11g Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges pragma autonomous_transaction trigger Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: https://www.techonthenet.com/oracle/errors/ora04091.php Sign up ORACLE After update trigger: solving ORA-04091 mutating table error up vote 2 down vote favorite I am trying to create a trigger: create or replace trigger NAME_OF_TRIGGER after insert or update on table1 REFERENCING OLD AS OLD NEW AS NEW for each row to fill in automatically a couple of non obligatory fields when updating/inserting on a table. This requires http://stackoverflow.com/questions/6915325/oracle-after-update-trigger-solving-ora-04091-mutating-table-error me to use a cursor that selects from table2 and also table1 (the subject of the trigger). Is there any way to avoid the mutating table error without using a temporary table for values or an autonomous transaction? sql oracle plsql triggers mutating-table share|improve this question edited Aug 2 '11 at 16:54 APC 87.1k1384184 asked Aug 2 '11 at 16:26 JoséNunoFerreira 150111 add a comment| 1 Answer 1 active oldest votes up vote 7 down vote accepted "Is there any way to avoid the mutating table error without using a temporary table for values or an autonomous transaction?" tl;dr no. The mutating table error is caused by querying the table which owns the trigger, or tables which are involved in a foreign key relationship with the owning table (at least in older versions of the database, not sure whether it still obtains). In a properly designed application this should not be necessary. This is why many people regard mutating tables as an indicator of poor data modelling. For instance, mutation is often associated with insufficient normalisation. To paraphrase Jamie Zawinski: Some people, when confronted wit
- 8:40 pm UTC Category: SQL*Plus – Version: 8.1.7 Latest Followup You Asked hello, i've got a table MRC and a trigger on it (AFTER INSERT) thus, after an insert in the table MRC, this trigger https://asktom.oracle.com/pls/apex/f?p=100:11:0%3A%3A%3A%3AP11_QUESTION_ID:9579487119866 has to determine if a new line must be inserted into an other table PLAN : for that, it does compare the :new values with the MOST RECENT enregistrement of MRC but i got a mutating table error i understand the problem but how can i get over ?? thanks Arnaud and we said... My personal opinion -- when I hit a mutating table error, I've got a serious fatal mutating trigger flaw in my logic. Have you considered the multi-user implications in your logic? Two people inserting at the same time (about the same time). What happens then??? Neither will see eachothers work, neither will block -- both will think "ah hah, I am first"... anyway, you can do too much work in triggers, this may well be that time -- there is nothing wrong with doing things in a mutating trigger in more straightforward fashion (eg: using a stored procedure to implement your transaction) but if you persist, you can use the technique: http://asktom.oracle.com/~tkyte/Mutate/index.html to avoid the mutating table constraint -- but I would avoid the situation that gets me there in the first place. The logic is a whole lot more understandable that way (and maintainable and testable and everything) Reviews Write a Review Ora-4091 May 05, 2003 - 5:45 pm UTC Reviewer: A reader We create trigger in the test server (8i) its working without error, and when we created at life (8) we get the following error: ORA-04091: table XXXX is mutating, trigger/function may not see it. Followup May 05, 2003 - 8:31 pm UTC they relaxed some of the constraining rules between 8.0 and 8.1 -- things are in general upwards (develop in 8.0 and goto 8.1) compatible but not backwards. Why I can't get the 4091 error when insert? January 05, 2004 - 3:39 am UTC Reviewer: Li ys from CHINA I only want to prove the mutating table by this triggers: CREATE TABLE r_Module ( Bureauno NUMBER(3), Moduleno NUMBER(3), primary key ( Bureauno, Moduleno ) ); CREATE OR REPLACE TRIGGER LimitTest BEFORE INSERT OR UPDATE ON r_Module FOR EACH ROW DECLAR