Ayuda Trigger
Publicado por Uriel (1 intervención) el 08/11/2014 05:06:21
Disculpen alguien podría ayudarme con este trigger
Lo que tiene que hacer es que cada vez que se inserte un nuevo libro en la tabla libro se actualice la tabla estadistica_genero.
Pero cuando inserto un libro me manda este error.
Si alguien me pudiera ayudar le estaría muy agradecido.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
create or replace trigger ai_libro
after insert on libro
for each row
DECLARE
total NUMBER(4);
promedio NUMBER(10);
begin
SELECT total_libros+1 into total
FROM estadistica_genero
where genero=:new.genero;
SELECT avg(precio) into promedio
FROM LIBRO
where genero=:new.genero;
update estadistica_genero
set TOTAL_LIBROS=total,PRECIO_PROMEDIO=promedio
where genero=:new.genero;
end;
Pero cuando inserto un libro me manda este error.
1
2
3
4
5
6
7
8
9
10
11
INSERT INTO LIBRO
VALUES('9781412160711','novela','El pendulo',50,100,'Edgar Alan',' ')
Informe de error -
Error SQL: ORA-04091: table LIBRERIA.LIBRO is mutating, trigger/function may not see it
ORA-06512: at "LIBRERIA.AI_LIBRO", line 9
ORA-04088: error during execution of trigger 'LIBRERIA.AI_LIBRO'
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.
Valora esta pregunta


0