I have to build a trigger that when a record is inserted in the table detalle_venta, enter the commission in the commission table, you have to calculate the commission (commission * amount) * 0.05, my trigger compiles, but when I insert a record in sale_detail tells me that: table STORE.DETALLE_SALE is mutating, trigger / function may not see it
CREATE OR REPLACE TRIGGER inserta_comision
AFTER UPDATE OR INSERT OR DELETE
ON detalle_venta
FOR EACH ROW
DECLARE
vprecio producto.precio%type;
BEGIN
SELECT P.precio
INTO vprecio
FROM detalle_venta D
JOIN producto P
ON ( D.id_producto = P.id_producto );
IF INSERTING THEN
INSERT INTO comision values ( :new.folio_venta, (vprecio*:new.cantidad)*.05, sysdate );
END IF;
END;
/