create or replace TRIGGER TG_TAB_FATURAMENTO AFTER INSERT ON ITENS_NOTAS BEGIN DELETE INTO TAB_FATURAMENTO; INSERT INTO TAB_FATURAMENTO SELECT N.DATA_VENDA, SUM(ITN.QUANTIDADE * ITN.PRECO) AS FATURAMENTO FROM NOTAS N INNER JOIN ITENS_NOTAS ITN ON N.NUMERO = ITN.NUMERO GROUP BY N.DATA_VENDA; END;
INSERT INTO NOTAS (NUMERO, DATA_VENDA, CPF, MATRICULA, IMPOSTO) VALUES ('005', TO_DATE('2019-01-03','YYYY-MM-DD'), '1471156710', '235', 0.1);
INSERT INTO ITENS_NOTAS (NUMERO, CODIGO, QUANTIDADE, PRECO) VALUES ('005','1040107', 12,10);
Erro a partir da linha : 37 no comando - INSERT INTO ITENS_NOTAS (NUMERO, CODIGO, QUANTIDADE, PRECO) VALUES ('005','1040107', 12,10) Erro na Linha de Comandos : 37 Coluna : 13 Relatório de erros - Erro de SQL: ORA-04098: gatilho 'THIAGOVASCONCELOS.TG_TAB_FATURAMENTO' é inválido e a revalidação falhou
https://docs.oracle.com/error-help/db/ora-04098/04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation" *Cause: A trigger was attempted to be retrieved for execution and was found to be invalid. This also means that compilation/authorization failed for the trigger. *Action: Options are to resolve the compilation/authorization errors, disable the trigger, or drop the trigger.
More Details : https://docs.oracle.com/error-help/db/ora-04098/