Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 3rd, 2004, 10:37 AM
asaducidiki asaducidiki is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 asaducidiki User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question trigger mutating

i have made a simple trigger whcih is doing nothing but just updating the attribute whose value goes down uder a specified value. code is

create or replace trigger dec_rawmaterial
after update on raw_material
for each row
when ( new.quantity_present < 500 )
begin
update raw_material
set quantity_present = quantity_present + 1000
where type = :new.type;
end;
/


what i do is

update raw_material
set quantity_present = 200
where type = 'PLAYCITE';

and error is

set quantity_present = 200
*
ERROR at line 2:
ORA-04091: table SCOTT.RAW_MATERIAL is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.DEC_RAWMATERIAL", line 2
ORA-04088: error during execution of trigger 'SCOTT.DEC_RAWMATERIAL'

Reply With Quote
  #2  
Old January 3rd, 2004, 11:30 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,009 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 14 h 3 m 17 sec
Reputation Power: 67
You cannot update the table that is being updated in an Oracle trigger.

If the type column is a primary key, you can change your trigger to:
Code:
...
begin
    :new.quantity_present = :new.quantity_present + 1000;
end;

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > trigger mutating


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT