Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> trigger with ora-04091

trigger with ora-04091

From: ing_ora <zana_f_at_hotmail.com>
Date: 21 Dec 2004 07:38:20 -0800
Message-ID: <1103643500.012919.298160@c13g2000cwb.googlegroups.com>


hello all,

I created a trigger on a coloum ( resultaat ) of a table ( z_wedstrijden ) after update for each row. in this trigger i called a procedure that make update in another table(z_spelers). but when i update table(z_wedsrtrijden) i get the error : ora-04091z_wedstrijden is mutating table......

i tried instead of row trigger a statement trigger with same trigger code but then the trigger not fired when i updated table
(z_wedstrijden). so does you know what is the cause of that ? and how
can i resolve it ? i appreciate your help.

Greetings,

Below is the definition of my trigger and the procedure that i call in that trigger.
--- trigger----------
CREATE OR REPLACE TRIGGER SYSTEM.UITVOER_TOTO AFTER UPDATE
OF RESULTAAT
ON SYSTEM.Z_WEDSTRIJDEN
REFERENCING NEW AS NEW OLD AS OLD
DECLARE
Cursor c_wedstrijden is select id from z_wedstrijden; r_wedstrijden c_wedstrijden%rowtype;
BEGIN
For r_wedstrijden in c_wedstrijden
Loop
p_bereken_totaal_scores(r_wedstrijden.id); end loop;
END ;

---------procedure----------------

CREATE OR REPLACE procedure p_bereken_totaal_scores
( p_speler_id in z_spelers.ID%type)

is
cursor c_voorspelling is select wedstrijd_id, voorspelling from z_voorspelling
where speler_id = p_speler_id;
r_voospelling             c_voorspelling%rowtype;
v_resultaat     z_wedstrijden.RESULTAAT%type;
begin
for r_voorspelling in c_voorspelling
loop
select resultaat
into v_resultaat
from z_wedstrijden
where id = r_voorspelling.wedstrijd_id;
if
substr(r_voorspelling.voorspelling,1,instr(r_voorspelling.voorspelling,'-',1,1)-1) = substr(v_resultaat,1,instr(v_resultaat,'-',1,1)-1) and
substr(r_voorspelling.voorspelling,instr(r_voorspelling.voorspelling,'-',1,1)+1,length(r_voorspelling.voorspelling)-instr(r_voorspelling.voorspelling,'-',1,1)) =
substr(v_resultaat,instr(v_resultaat,'-',1,1)+1,length(v_resultaat)-instr(v_resultaat,'-',1,1)) then
update z_spelers
set totaal_scores = totaal_scores + 1
where id = p_speler_id;
commit;

   end if;

      end loop;
  end p_bereken_totaal_scores; Received on Tue Dec 21 2004 - 09:38:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US