I'm having the following error when executing my trigger, how could I resolve it?
ERROR
The error when I insert insert into the product-purchase table to calculate total INSERT into purchase_product (CPR_CODIGO, PRO_CODIGO, CPP_QTDE, CPP_PRECO, CPP_DESCONTO) VALUES (1,2,7,87,0); ORA-04091: the ADMIN.COMPRA_PRODUTO table is mutant; the trigger / function may not be able to find it ORA-06512: under "ADMIN.TRG_TOTAL_COMPRA_PRODUTO", line 3 ORA-04088: Error during trigger execution 'ADMIN.TRG_TOTAL_COMPRA_PRODUTO'
TRIGGER
CREATE OR REPLACE TRIGGER "TRG_TOTAL_COMPRA_PRODUTO"
BEFORE INSERT OR DELETE OR UPDATE ON COMPRA_PRODUTO
FOR EACH ROW
DECLARE
BEGIN
UPDATE COMPRA_PRODUTO SET CPP_TOTAL =
(
SELECT ((CPP_TOTAL * CPP_QTDE) - (((CPP_TOTAL * CPP_QTDE) * CPP_DESCONTO) / 100)) FROM COMPRA_PRODUTO
WHERE CPP_CODIGO = :NEW.CPP_CODIGO AND
PRO_CODIGO = :NEW.PRO_CODIGO
)
WHERE CPR_CODIGO = :NEW.CPR_CODIGO;
END;
Insert
INSERT INTO COMPRA_PRODUTO (CPR_CODIGO, PRO_CODIGO, CPP_QTDE, CPP_PRECO, CPP_DESCONTO)
VALUES (1,3,9,90, 0);