Frank van Bortel schrieb:
> Jürg Schaufelberger wrote:
>
>>Hello
>>
>>I work with oracle 8.1.7 and I wrote the following trigger and
>>compiled it successfully:
>>
>>CREATE OR REPLACE TRIGGER
>> AV_BB_EINZELPUNKT_EXAKTDEF
>> AFTER INSERT OR UPDATE OF ID_ART
>> ON AV_BB_EINZELPUNKT
>> FOR EACH ROW
>> BEGIN
>> IF :NEW.ID_ART IN (0) THEN
>> UPDATE AV_BB_EINZELPUNKT SET ID_EXAKTDEFINIERT = 0;
>> ELSE
>> UPDATE AV_BB_EINZELPUNKT SET ID_EXAKTDEFINIERT = 1;
>> END IF;
>> END;
>>
>>then I executed the SQL statement:
>>
>>UPDATE AV_BB_EINZELPUNKT set id_art = 0
>>where fid = 1;
>>
>>and got the following error
>>
>>FEHLER in Zeile 1:
>>ORA-04091: Tabelle AV_CHA.AV_BB_EINZELPUNKT wird gerade geändert,
>>Trigger/Funktion darf es nicht sehen
>>ORA-06512: in "AV_CHA.AV_BB_EINZELPUNKT_EXAKTDEF", Zeile 3
>>ORA-04088: Fehler bei der Ausführung von Trigger
>>'AV_CHA.AV_BB_EINZELPUNKT_EXAKTDEF'
>>
>>What's wrong ? Any idea ? Thanks for answers.
>>
>>
>>
>
>
> You have a "Mutating Table" - standard recipe to avoid that.
> By the way: why do you update *all* records if only (possibly)
> one is updated?!?
>
You are correct, in my post i've overlooked, that all records were
updated. But that is hopefully not the proper logic behind, so, maybe my
example is still useful...
Best regards
Maxim
Received on Thu Sep 15 2005 - 14:15:15 CDT