Questions tagged [mutating-table]

Mutating table errors generally happen when a trigger tries to reference/modify the same table on which trigger is firing on.

Mutating table/trigger errors are mostly caused when you try to reference/modifies the table on which the trigger is firing.

The error generally refers to a flaw in application logic or data model.

APC explains the data model flaw:

Some highly viewed questions/solutions on this

64 questions
0
votes
1 answer

Oracle SQL Creating Trigger to Increment a Sequence Number For Each Row

I'm trying to create a trigger but I have learned I can not design it as in my first attempt, which I'm showing below. This will cause a 'mutating table' error due to selecting from the table as it is being modified. It actually didn't cause this…
bikeactuary
  • 447
  • 4
  • 18
0
votes
2 answers

Mutating table - trigger error

I have to implement the following trigger: The total number of votes, per election year, of the elections after 1960, does not exceed 538 However, I get the mutating table error. I understand why do I get the error but I cannot see another…
MonicaS
  • 155
  • 1
  • 3
  • 18
0
votes
2 answers

Oracle Trigger - table name is mutating, trigger/function may not see it

I am having an Oracle database with following Scenario(simplified): Projects Params ------------- ----------- PROJ_ID SCODE PARAM_ID PARAM_TYPE PROJ_ID PARAM_VALUE 1000 123 …
Deniz Gezgin
  • 53
  • 1
  • 7
0
votes
2 answers

SQL Using Procedures Along With Triggers

I am trying to create some triggers and procedures to auto populate some tables in my database. I have two tables, Users and Utilities. Users Table: CREATE TABLE USERS ( User_id Number(38,0) NOT NULL PRIMARY KEY, User_name char(18) NULL ,…
Blued00d
  • 170
  • 4
  • 23
0
votes
1 answer

Mutating table error thrown from stored procedure fired by an after insert trigger

I have a requirement to call a stored procedure via 'after insert' trigger whenever data is inserted into table but I run into "error ORA-04091: table TEST.EMP is mutating, trigger/function may not see it". I understand the reason behind this error…
0
votes
2 answers

PL/SQL Trigger gets a mutating table error

My trigger wants to check if a 'new' manager supervises no more than 5 employees. Manager supervising only 5 people are in BLOCKED_MANAGER table(ssn,numberofemployees). Finally, every update is recorded in SUPERLOG…
Franktrt
  • 373
  • 1
  • 8
  • 18
0
votes
1 answer

Mutating table issue in after row trigger

I've created a package that contains one procedure and one function. Function is called by the trigger on insert after each row on the table REZULTAT. create or replace trigger rezultat_compound for insert on rezultat compound trigger v_igid …
user3885274
  • 5
  • 1
  • 3
0
votes
1 answer

Oracle Trigger - On update I need to update other rows in same table - getting mutate error

As part of a nasty hack I've been asked to do, I need to modify a trigger to update associated records in a table - but am getting the mutating table error. Data looks like this: roster table Id person_id route_id active_ind 1 1 1 …
Dave Tapson
  • 810
  • 1
  • 9
  • 22
0
votes
2 answers

PLSQL: mutating table stopping my 'before update trigger'. What to do?

I've finally compiled my trigger , but now I'm getting a mutating table error when I do the relevant update: ORA-04091: table KEV.STORE_COPY is mutating, trigger/function may not see it ORA-06512: at "KEV.SOLD", line 5 ORA-04088: error during…
COOLBEANS
  • 729
  • 3
  • 13
  • 31
0
votes
1 answer

Oracle 11g trigger to replace part of a text string

I'm having issues with a trigger that keeps mutating. The goal of the trigger is when a file path is updated change part of the string. Here is what I have so far, it compiles just fine. CREATE OR REPLACE TRIGGER TAU_ATTACHMENTS AFTER UPDATE ON…
PhelpsK
  • 207
  • 2
  • 3
  • 7
0
votes
2 answers

Trigger avoiding mutating table and updating :new.values

I have a small table looking like this table People ( name VARCHAR(20) PRIMARY KEY ,group NUMBER(4) ); And i need to create trigger (or triggers) thats will allow below rules to work: - 1 if there are more then 10 names in group i need to…
plomien
  • 77
  • 2
  • 11
0
votes
2 answers

Mutating Trigger Oracle

I have two tables main and hist. I want to copy a row from main table whenever its datetime column is modified to hist and reset the modified colums in the main to null except one column. However I am getting mutating trigger error. Please…
0
votes
1 answer

Oracle SQL Trigger mutating when implemeneted

Having trouble with this trigger when it runs suring a insert or update operation. The trigger gets created without errors though. The objective is to check if the invoice_total is bigger than the total of payment_total + credit_total. Any help…
Nimesh Wicks
  • 19
  • 1
  • 7
0
votes
1 answer

Oracle Trigger creation - table is mutating; trigger may not read or modify it

As the table is mutating the following trigger does not work as I believe the SQL statement within the trigger cannot be executed against a mutating table, however as I am not on 11g I cannot create a compound trigger. I have tried including PRAGMA…
pwlm
  • 174
  • 2
  • 2
  • 19
0
votes
1 answer

Get ID of updated entry on Update trigger - mutating table error

I'm trying to create an update trigger but I keep bumping on the "mutating table" error. The main idea is a sell&buy database with user ratings. Basically I want to, everytime a rating on the PRODUTOS table is updated, recalculate the seller's…
A. Capelo
  • 73
  • 1
  • 8