Home » RDBMS Server » Server Administration » Trigger causes Error. Why?
Trigger causes Error. Why? [message #369803] Fri, 13 October 2000 10:44 Go to next message
Fabian
Messages: 19
Registered: October 2000
Junior Member
Hello
I have a problem again.
on modifications on special Fields in one or more Tables
the calculating routine ALLE_BEITRAEGE in the Package BERECHNUNGEN should be started.

I tried this with following trigger:

CREATE OR REPLACE TRIGGER adressen_trigger_ber
AFTER UPDATE
OF geb_jahr
ON adressen
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE

CURSOR cBetrieb (adrnr IN VARCHAR2) IS
SELECT BWRT_GEM,BWRT_ZKR,BWRT_BET
FROM BETRIEB
WHERE ADRNUMMER=adrnr;
cBetrieb_rec cBetrieb%ROWTYPE;

Begin
open cBetrieb(:OLD.ADRNUMMER);
fetch cBetrieb into cBetrieb_rec;
if cBetrieb_rec.BWRT_GEM IS NOT NULL then
BERECHNUNGEN.ALLE_BEITRAEGE (cBetrieb_rec.BWRT_GEM,
cBetrieb_rec.BWRT_ZKR,cBetrieb_rec.BWRT_BET);
end if;
close cBetrieb;
End;

My problem is, that BERECHNUNGEN.ALLE_BEITRAEGE access on the table adressen of which i fired the trigger.

This allways ends whith the Error Message
ORA-04091 table adressen is mutating trigger may not see it.

I think I know what the Problem is, but I don't know
how to avoid it. Because I fire the Trigger AFTER UPDATE.

Does anybody know an alternative to the triggers or
how to avoid this Error??

Thank a lot for Your replies.

Regards
Fabian
Re: Trigger causes Error. Why? [message #369833 is a reply to message #369803] Thu, 19 October 2000 08:56 Go to previous message
Muralee
Messages: 2
Registered: October 2000
Junior Member
You are trying to access the table which you are trying to update, adressen , which will cause a cyclic reference. I think you should do the insert or update on a temporary table with same structure as adressen and update it back using an after statement trigger.
Previous Topic: Oracle Database
Next Topic: Thanks Prem
Goto Forum:
  


Current Time: Sun Apr 28 11:08:46 CDT 2024