Ok j ai vu le post cela ma permis de cerner la chose et par ailleurs j ai modifié mon code ,mais j ai un problème de mutation mais je vois pas comment le relever//
voici mon code Trigger
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
create or replace TRIGGER DECLANCHE
AFTER INSERT ON CONCERNER
FOR EACH ROW
DECLARE
mttop operation.mtt_op%type;
sensop concerner.sens%type;
BEGIN
select sens into sensop from concerner where SENS =SENS;
IF sensop = 1 THEN
UPDATE COMPTE set avoir_cpt = solde_cpt + ( SELECT mtt_op FROM operation )
WHERE num_cpt = :new.num_cpt ;
ELSIF sensop = 2 THEN
UPDATE COMPTE set avoir_cpt = solde_cpt - ( SELECT mtt_op FROM operation )
WHERE num_cpt = :new.num_cpt ;
End if ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
raise_application_error(-2001, 'numero du compte non valide');
END; |
quand j insère la donnée
INSERT INTO CONCERNER (num_op, num_cpt, sens ) VALUES (5, '0084', 2);
j obtiens cet erreur
Erreur commençant à la ligne: 1 de la commande -
INSERT INTO CONCERNER (num_op, num_cpt, sens ) VALUES (5, '0084', 3)
Rapport d'erreur -
Erreur SQL : ORA-04091: table NGUIMBIS1.CONCERNER is mutating, trigger/function may not see it
ORA-06512: at "NGUIMBIS1.DECLANCHE", line 5
ORA-04088: error during execution of trigger 'NGUIMBIS1.DECLANCHE'
04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
*Cause: A trigger (or a user defined plsql function that is referenced in
this statement) attempted to look at (or modify) a table that was
in the middle of being modified by the statement which fired it.
*Action: Rewrite the trigger (or function) so it does not read that table.
Partager