473,581 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mutating Error in Triggers

151 New Member
Can Someone help me how to avoid mutating error while using triggers.


I work on oracle apps. I created a vacation rule such that responsibility is delegated to other person. These details are captured in wf_routing_rule s.

I created a procedure that takes the values from wf_routing_rule s and sends mail using utl_smtp. I created a trigger such that for every row insert in wf_routing_rule s, this procedure is called.

I know that doing a transaction and trigger on same table wil give mutating error.

Is there a way to avoid this ( other than changing the table name).

Glad if there is a different solution for this too.

Vamsi
Mar 5 '09 #1
16 7021
vamsioracle
151 New Member
I tried by using Pragma autonomous_tran saction.

now i get an error

java.sql.SQLExc eption: ORA-01403: no data found
ORA-01403: no data found
ORA-06512: at "APPS.CBTT_DELE GATE_RULE_PROC" , line 19
ORA-06512: at "APPS.CBTT_DELE GATE_RULE_TRIGG ER", line 7
ORA-04088: error during execution of trigger 'APPS.CBTT_DELE GATE_RULE_TRIGG ER'
ORA-06512: at line 6


Is the trigger firing even before insert . The above error is on the apps screen,vacation rule creation.

vamsi
Mar 5 '09 #2
amitpatel66
2,367 Recognized Expert Top Contributor
I assume your trigger is after insert trigger. I suggest you to use :new values in the trigger and pass them as a parameter to the PROCEDURE instead of useing a SELECT query in the PROCEDURE.

AFTER INSERT, just pick the data from the table using :new clause and pass them as input parameter to the procedure you are calling, and do the rest.
Mar 10 '09 #3
vamsioracle
151 New Member
Thanks dude

but it is better if i post my code.

----------------------------
Code:

create or replace trigger xx_routing
after insert
on wf_routing_rule s
for each row
begin


--- here i call the procedure that has the following code-------

select role,attribute into x,y from wf_routing_rule s where begin_date >= to_date(sysdate );

utl_smtp.conn(h ost,port)
--------

end procedure;
--------------------

So if you can observe the trigger and the procedure uses the same table.I dont have any other chance. As soon a row is inserted in that table , i must capture that row and send through utl_smtp.

is there any other solution for this.

vamsi
Mar 11 '09 #4
vamsioracle
151 New Member
Thanks dude

but it is better if i post my code.

----------------------------
Code:

create or replace trigger xx_routing
after insert
on wf_routing_rule s
for each row
begin


--- here i call the procedure that has the following code-------

select role,attribute into x,y from wf_routing_rule s where begin_date >= to_date(sysdate );

utl_smtp.conn(h ost,port)
--------

end procedure;
--------------------

So if you can observe the trigger and the procedure uses the same table.I dont have any other chance. As soon a row is inserted in that table , i must capture that row and send through utl_smtp.

is there any other solution for this.

vamsi
Mar 11 '09 #5
amitpatel66
2,367 Recognized Expert Top Contributor
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. create or replace trigger xx_routing
  3. after insert
  4. on wf_routing_rules
  5. for each row
  6. begin
  7.  
  8. proc1(:new.role,:new.attribute);
  9.  
  10. --- here i call the procedure that has the following code-------
  11.  
  12. /*select role,attribute into x,y from wf_routing_rules where begin_date >= to_date(sysdate);*/
  13. --now do what ever you want to with the input parameters rolw and attribute
  14.  
  15. utl_smtp.conn(host,port)
  16. --------
  17.  
  18. end procedure;
  19.  
Mar 12 '09 #6
madankarmukta
308 Contributor
@amitpatel66
Hi amit,

I have a doubt over your solution.Kindly correct me if I am getting wrong.

U did the desired operation of selecting the row within the procedure which finally refers to wf_routing_rule s.will that solve the problem of mutation..?

If that's true we can put "selecting the row " into child transaction i.e. use of autonomous transaction may solve the problem; as per my understanding.

Thanks!
Mar 12 '09 #7
vamsioracle
151 New Member
Dude

I tried autonomous transaction too , it didn't work. Let me try this new solution and get back.
Mar 12 '09 #8
Jibran
30 New Member
Refer to the following link: http://www.dba-oracle.com/t_avoiding...able_error.htm, it has some good suggestions to prevent mutating errors.
Mar 12 '09 #9
amitpatel66
2,367 Recognized Expert Top Contributor
@madankarmukta,

I have commented the SELECT statement that is used in the Procedure by the @OP. That select statement is causing all the problem. Now the @OP needs the values of the latest record inserted in to table so that can be accessed just by using :NEW clause in the TRIGGER and pass those values as an INPUT parameter from a TRIGGER to a PROCEDURE.

I hope I cleared your doubt!!
Mar 13 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4711
by: robert | last post by:
i've found the solution threads on changing a column on insert. works fine. question: - will one package serve for all such triggers, or does there need to be a package defined to support each table? my o'reilly book doesn't say, nor do the threads i found.
4
7455
by: M | last post by:
Hello, I have a very simple table, and want to create a trigger that updates the date column entry (with the current date), whenever a row gets modified. Is there a simple way of fixing this, or would I have to create 3 extra triggers, a package, etc., as described in most posts about mutating table errors? Could you please explain to me...
4
7044
by: M Mueller | last post by:
Hello - I'm using Oracle 8i and am running into the infamous mutating table error on an AFTER INSERT OR UPDATE FOR EACH ROW trigger. I have seen examples for getting around mutating table errors if you either need access to the :old or the :new values within a trigger. But what if you need access to both? Or is this even possible (I'm...
0
2142
by: hankr | last post by:
I have only a developer's level knowledge of Oracle, though I have access to DBA tools. Searches through the docs have not been fruitful, so I thought I'd try here. I am getting an error on a simple 1-row I-SQL delete statement that a different table may be "mutating" and the transaction is then rolled-back. I understand what this means,...
2
14779
by: Karl | last post by:
Exception EDBEngineError in module Cserv.exe at 0013E2C8. General SQL error. SQL0727N An error occurred during implicit system action type "1". Information returned for the error includes SQLCODE "-101", SQLSTATE "54001" and message tokens "". SQLSTATE=56098. I get the above error when using an application that performs an insert into a...
2
12201
by: Reshmi Jacob | last post by:
Hello, Can any one help me in creating a trigger to update system date into a table while inserting a record into that table. I tried it like this, it is showing error !!! The following error has occurred: ORA-04091: table ACG.CENTREMST is mutating, trigger/function may not see it ORA-06512: at "ACG.CENTREMST_INSERT", line 5...
0
1540
by: AYAN MUKHERJEE | last post by:
I have 2 tables. 1) emp_test, 2) newemp_test. I had created a trigger to insert automatic data in the table no. 2 , as soon as a row of information is inserted in table no. 1. The Trigger had been successfully done, but as I try to insert a row in the table after running the Trigger this error is getting generated....
3
3703
by: extremexpert | last post by:
Hai all, I have two tables like hdr and det. I would like to create the trigger for the situation ' 1.Delete Det table records, if any record is deleting in hdr table 2. Delte hdr table records, if any record is deleting in det table '. I have created the trigger for both the tables, but i am facing ' Mutating Error'.... Any...
1
1637
by: mask | last post by:
I am writing a trigger for delete event of employee table (PK - empno, Mrgid - Self referencing key ) in oracle .In the trigger , i wish to update the rows of the same table which have mgr id equal to the empno being deleted, and set the mgrid=null. The problem coming here is of Mutating table.Is there a simple workaround of this problem? Thx n...
0
7876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6563
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3832
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.