我需要在歷史數據表中插入「記數」,當我插入「ALUGUER」的東西觸發器應在「HISTORICO」插入一行:觸發用於插入後
下了扳機:
create or replace
trigger ADD_HISTORICO
AFTER INSERT
ON ALUGUER
FOR EACH ROW
DECLARE
cod_aluguer_p NUMBER(6,0);
cod_veiculo_p NUMBER(6,0);
BEGIN
SELECT ID_ALUGUER INTO cod_aluguer_p
FROM ALUGUER;
SELECT COD_VEICULO INTO cod_veiculo_p
FROM ALUGUER;
INSERT INTO HISTORICO(ID_ENTRADA,DESCRICAO,DATA_REGISTO,NOVO_VEICULO,NOVO_ALUGUER)
VALUES(SEQ_HISTORICO.nextval,'NOVA DESCRIÇÃO','21/11/2013',cod_veiculo_p,cod_aluguer_p);
END;
錯誤報告:
SQL Error:
ORA-04091: BDDAD_DL1.ALUGUER table is mutating, trigger can not read or modify
ORA-06512: at "BDDAD_DL1.ADD_HISTORICO", line 6
ORA-04088: error during execution of trigger 'BDDAD_DL1.ADD_HISTORICO' 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 que 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.
謝謝您的時間。它幫助了很多。 – Vyward