Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Compiled Trigger throws error

Re: Compiled Trigger throws error

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Thu, 15 Sep 2005 21:37:17 +0200
Message-ID: <dgcihc$b25$02$1@news.t-online.com>


Frank van Bortel schrieb:

> Maxim Demenko wrote:
> 

>>Jürg Schaufelberger schrieb:
>>
>>
>>>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.
>>>
>>>
>>>
>>
>>Instead of update you should do assignment to given fields of :NEW record
>>
>>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
>> :NEW.ID_EXAKTDEFINIERT := 0;
>> ELSE
>> :NEW.ID_EXAKTDEFINIERT := 1;
>> END IF;
>> END;
>>
>>Best regards
>>
>>Maxim
> 
> 
> Unless he actually means up update multiple records.
> In that case, a second trigger (after statement) would be
> needed to handle that. Part of the standard recipe for
> mutating tables...
> 

Frank, please, notice, my followup to your first posting was before your followup to mine ;-)
Yes, i'm fully agreed.

Best regards

Maxim Received on Thu Sep 15 2005 - 14:37:17 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US