What is mutating table?

Answer Posted / purushottam

All the above suggested point is fine but addition on it is
when you are going to use the aggregate function for same
table then also be the mutating table error will occur.

example:

create table t(x numner);
/

create or replace trigger t_af_trigg
before insert into t
for each row
declare
n integer;
begin
select count(*) into n from t;
dbms_output.put_line('there are ' || n || ' rows in t');
end;
/

insert into t values(1);
error:
ORA-04091: table MISC.T is mutating, trigger/function may
not see it
ORA-06512: at "MISC.T_AF_TRIGG", line 5
ORA-04088: error during execution of trigger 'MISC.T_AF_TRIGG'

This example value addition of Vivek's suggession

"Mutating means that some one is trying to access the table
currently being held by some other non-committing
transaction(i.e. in Locked state)"

Is This Answer Correct ?    20 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how can we take a backup of a mysql table and how can we restore it. ? : Sql dba

521


How can you fetch common records from two tables?

590


Can we create foreign key without primary key?

536


What is the purpose of a secondary key?

513


Does sql*plus also have a pl/sql engine?

563






how to get @@error and @@rowcount at the same time? : Sql dba

530


how many tables will create when we create table, what are they? : Sql dba

544


How global cursor can be declare with dynamic trigger ?

1750


What are different functions in sql?

519


What is the unique index?

525


Is sql port 1433 encrypted?

578


Can you select everything, but 1 or 2 fields, without writer's cramp?

500


Can we use rowid as primary key?

547


How does an execution block start and end in pl sql?

500


How many sectors are in a partition?

564