我在BEFORE INSERT TRIGGER上看到一個奇怪的錯誤,我不明白。即使閱讀了這裏發佈的類似問題的多個問題。java.sql.BatchUpdateException:在插入觸發器之前的ORA-04091
failed to process "method": category_id = 'foo' and request_id = '99' error: java.sql.BatchUpdateException: ORA-04091: table SCHEMA.ANIMAL_TABLE is mutating, trigger/function may not see it ORA-06512: at "SCHEMA.TRIGGER_NAME", line 7 ORA-04088: error during execution of trigger 'SCHEMA.TRIGGER_NAME'
這裏是觸發:
CREATE OR REPLACE TRIGGER TRIGGER_NAME
BEFORE INSERT ON animal_table FOR EACH ROW WHEN (NEW.animal_type = 'cats')
DECLARE base_animal_id NUMBER(19,0); base_amount NUMBER(19,0);
BEGIN
SELECT animal_nbr INTO base_animal_id
FROM animal_table
WHERE category_id = :NEW.category_id AND summary_id = :NEW.summary_id
AND animal_type = 'special';
SELECT animal_amount INTO base_amount
FROM animal_table
WHERE category_id = :NEW.category_id AND summary_id = :NEW.summary_id
AND animal_type = 'special';
IF :NEW.category_id = 'foo' THEN
:NEW.animal_info1 := base_animal_id;
:NEW.animal_info2 := base_amount;
:NEW.animal_info3 := '00';
END IF;
END;
我知道關於它的觸發被關押在同一個表的修改規則,但我也是紅色的東西,就應該更換新的列時工作,僅適用於:NEW字段。我也認爲它可能缺少UPDATE作爲觸發事件,但情況並非如此。任何人都可以幫助我嗎?因爲我是觸發器和PL/SQL的新手。
謝謝,L ukas ...我正準備這樣做。 –