How to solve mutating table error?
I compiled the trigger below successfully:
CREATE OR REPLACE TRIGGER avail_products
BEFORE INSERT ON orders_tbl
FOR EACH ROW
DECLARE
m_prodqty products_tbl.prod_qty%TYPE;
m_ordered orders_tbl.ord_qty%TYPE;
m_prodid orders_tbl.prod_id%TYPE;
BEGIN
SELECT p.prod_qty, o.ord_qty, o.prod_id
INTO m_prodqty, m_ordered, m_prodid
FROM products_tbl p, orders_tbl o
WHERE ord_num=:NEW.ord_num;
IF m_prodqty>=m_ordered THEN
UPDATE products_tbl
SET prod_qty=prod_qty-m_ordered
WHERE prod_id=m_prodid;
ELSE
RAISE_APPLICATION_ERROR(-20101,'Product is not available');
END IF;
END;
However, when I run my PL/SQL block as follows:
DECLARE
v_max NUMBER;
BEGIN
SELECT MAX(ord_num)+1
INTO v_max
FROM orders_tbl;
INSERT INTO orders_tbl(ord_num, cust_id, prod_id, ord_qty, ord_date, dvy_date, refund)
VALUES (v_max, &cust_id, &prod_id, &ord_qty, '&ord_date', '&dvy_date',0);
COMMIT;
END;
UPDATE orders_tbl
SET refund=0.1*(SELECT price FROM products_tbl WHERE prod_id=(SELECT prod_id FROM orders_tbl WHERE ord_num=(SELECT MAX(ord_num) FROM orders_tbl)))
WHERE ord_num = (SELECT MAX(ord_num) FROM orders_tbl) AND dvy_date>ord_date+3;
COMMIT;
It gives me these errors:
ERROR at line 1:
ORA-01403: no data found
ORA-01403: no data found
ORA-06512: at "SYSTEM.AVAIL_PRODUCTS", line 9
ORA-04088: error during execution of trigger 'SYSTEM.AVAIL_PRODUCTS'
ORA-06512: at line 10
I try to debug it again and again but still can't find the mistake. So I change the trigger option to AFTER INSERT, then I got the error message that the table is mutating and trigger migh not see it. Anyone know how to solve this problem?
ERROR at line 2:
ORA-04091: table SYSTEM.ORDERS_TBL is mutating, trigger/function may not see it
ORA-06512: at "SYSTEM.AVAIL_PRODUCTS", line 13
ORA-04088: error during execution of trigger 'SYSTEM.AVAIL_PRODUCTS'
null
This extract from an earlier post might be of help:
You can solve this problem by using following thing
1)create a view on same table with all fields
and write trigger on table (insert,update or delete ) while inserting or updating or deleting row from table read from view.
(Mutating error come when you are reading from one table and want to update,insert or delete row of same table).
2)create a temporary table(but it is possible in 8i onword only) same as table on which you want to write trigger,while updating,inserting or deleting rows of table read from temporary table and after your work is over temporary table auotomatically drop (see proper command in oracle documentation to create temporary table).
null
Similar Messages
-
Hi,
I want a solution for mutating table error. I am a newbie in oracle.
I'll explain my scenario.
There are two tables TEACHER and STUDENT
both are linked using the field 'tid'. the foreign key relation is given as ON DELETE CASCADE
so if i delete a row from teacher , the corresponding rows in student get deleted, but i want to back up all the students who comes under that teacher, who is getting deleted.
I tried in TRIGGER, but getting mutating table error.
Please help
Thanks in advance
DivyaThis extract from an earlier post might be of help:
You can solve this problem by using following thing
1)create a view on same table with all fields
and write trigger on table (insert,update or delete ) while inserting or updating or deleting row from table read from view.
(Mutating error come when you are reading from one table and want to update,insert or delete row of same table).
2)create a temporary table(but it is possible in 8i onword only) same as table on which you want to write trigger,while updating,inserting or deleting rows of table read from temporary table and after your work is over temporary table auotomatically drop (see proper command in oracle documentation to create temporary table).
null -
i am getting mutating table error in triggers how to avoid this error
Hi,
You posted another question today in the SQL and PL/SQL forum, and that is also where you should have posted this:
PL/SQL
The SQL Developer (Not for general SQL/PLSQL questions) forum is only for questions regarding the SQL Developer tool. Please mark this as answered.
Regards,
Gary -
i am trying to updata any row at the time i am getting mutating table error for some triggers
fired on that table.what is the resonn and how to solve this problem,plz..helpHere's a good resource
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:290416059674 -
Hi All,
I am getting the “ORA-04091 - mutating table error" when my trigger on a table "fnd_flex_values" fires. As I understand it, this error is occuring because, the users are trying to add rows to this table (it is an after insert trigger) and the trigger is trying to get values from the same table.
Any suggestions on how to get around the mutating table error?
My trigger code :
CREATE OR REPLACE TRIGGER "APPS".ST_BU_PARENT_CC
after insert on APPLSYS.FND_FLEX_VALUES REFERENCING OLD AS OLD NEW AS NEW
for each row
Declare
v_flex_value varchar2(150) :=null;
v_desc varchar2(2) := null;
v_createdby number :=null;
v_lstupdby number :=null;
v_lstupdlogin number :=null;
begin
if inserting then
select a.last_update_login,a.last_updated_by,a.created_by,a.flex_value,
rtrim(substr(description,instr(b.description,',')+1,5))
into v_lstupdlogin,v_lstupdby,v_createdby,v_flex_value,v_desc
from fnd_flex_values a,
fnd_flex_values_tl b
where a.flex_value_id = b.flex_value_id
and a.flex_value_set_id = :new.flex_value_set_id
and a.flex_value_set_id = 1009635
and (a.flex_value like '1%' or a.flex_value like '7%')
order by flex_value asc;
insert into applsys.fnd_flex_value_hierarchies
values(:new.flex_value_set_id,v_desc||'STO',v_flex_value,v_flex_value,sysdate,v_lstupdby,sysdate,v_createdby,null,null,null);
insert into applsys.fnd_flex_value_norm_hierarchy
values(:new.flex_value_set_id,v_desc||'STO','P',v_flex_value,v_flex_value,sysdate,v_lstupdby,sysdate,v_createdby,v_lstupdlogin,null,null);
end if;
exception
when no_data_found then
raise;
end;Thanks,
Chiru>>
Any suggestions on how to get around the mutating
table error?
This link by Tom Kyte should help you with the
"mutating table" error.
http://asktom.oracle.com/tkyte/Mutate/index.html
pratzPratz,
Thanks for the quick reply. I am trying to create a temp table (log_table) but having the "insufficient privilages" issues.
Thanks,
Chiru -
HOW TO SOLVE THE R6034 ERROR IN ITUNES INSTALATION
I need toknow how to solve the R6034 error in itunes instalation becouse y can´t buk up muy phone
How to solve this ?
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-> int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal; -
I have a brand new PC that is MORE than adequate. I have once succeeded in burning a CD after learning all about time tracks and merging them. (made a few with only ONE track)
Two things:
1) I find that I must add a CD marker at the end of the WAV because Audition CS6 erases whatever is the last CD marker I've made. Very frustrating but now I know I have to do this but I have no idea WHY!!
2) Right now I have a WAV that is just over 1 hour and 3 minutes with a total of 637.74MB of info. When I try to export/burn a CD, I get an error message stating "The amount of audio to burn will not fit.......". I am using TDK 700MB blanks with a Pioneer Blu-ray burner.
Obviously it will fit.
What am I doing wrong, all of a sudden?Hey ryclark,
Thanks for responding. Something else is going on here.....
Here's what I re-replied to our friend...
Thanks for the response.
When I built this computer last Nov/Dec, it was built with the second
fastest Intel 7i, quad-core chipset on an 64-bit ASUS motherboard. It's running
Win 7 Pro. It has a 500GB SSD "C" drive with another 14 TB of true hard
drive space. It is set up with 64 bit. I had been using Audition CS3 for many
years and even go back to it's origin: Cool Edit and Cool Edit Pro. My
learning curve was minimal, sans the CD burning, which I used other software
for which is now antiquated, so I need Audition for this. Between this and
IZotope 3 I've repaired and improved many a recording. All-in-all extremely
useful software.
As for the idea "to burn it anyway", well the error message comes up and
that's it - if I "X" out of that message and try to burn again the message
comes back - so Audition will not let me. It is convinced that this file is
longer than it really is, but only when I add track marks to it!
There are only 11 tracks.
I was able to burn a CD of this same file but without all the track marks,
so the same exact file length/size will burn, only as the one track.
I've also succeeded in burning other WAV's , both greater and smaller, with
and without multiple track marks, without issue. Of course all with less
than the CD's max. capacity.
This problem seems to be with this one file. I've even re-made/re-recorded
the file from scratch with no change. There's something else going on here
that I can't put my finger on. (I am "recording" LP's and making personal
CDs of them)
Also, only from time to time, I have another error after burning a CD that
states it could not verify the CD. For this I assume it is the blank rather
than AA? The first might burn without issue and with the second burn I
get the error. It is near the end of a stack of blanks, so.....
As for the need to "mark the end" of the file makes a lot of sense but of
all the other CD track-marking software I've used, none needed one to do
this, but this IS Adobe after all.
You'd think there might be a smidge of intuitiveness with Adobe, but maybe
not.
- Mark
In a message dated 8/2/2014 8:11:52 A.M. Eastern Daylight Time,
[email protected] writes:
How to solve Audition CS6 error "The amount of audio to burn will not fit
on the CD........."?
created by ryclark (https://forums.adobe.com/people/ryclark) in
Audition CS5.5, CS6 & CC - View the full discussion
(https://forums.adobe.com/message/6605916#6605916) -
HT201405 how to solve time machine error-1
how to solve time machine error-1
I checked the pondini fixes and ended up doing the following - in case this could help someone else with OSX Lion and Time Capsule... http://pondini.org/TM/Troubleshooting.html
First, I downloaded and used Airport Utility 5.6 instead of 6.1 - BTW, I had to attempt download and installation THREE times before the program actually installed. Be persistant.
Pondini #5: It's possible some names (of all things!) may be a problem. See item C9. I had to re-name my Mac, Time Capsule, network, etc... to remove all apostrophes and spaces.
Pondini #7: If you have WD SmartWare installed on Lion, it's not compatible, per RoaringApps, and there are reports it can cause this problem as well. Use Western Digital's uninstaller, or delete the app from /Applications and the files com.wdc.WDDMservice.plist and com.wdc.WDSmartWareServer.plist from /Library/LaunchDaemons. There may also be a file in Library/Application Support.
I then had to shut down computer, unplug Time Capsule, unplug modem; plug everything in again, then reboot computer; then had to go to Apple- System Preferences- Network- and reselect my Time Capsule to connect to WiFi again.
Then opened Time Machine preferences again and attempted back up - it worked! -
Mutating table error in Trigger
i was asked to create a trigger like...
1. whenever a row inserted into TFILE, a select statment will be used to bring some data from different tables using a join(including FILE_TABLE)
and then inserting selected values into a new table NEW_TAB.
2. whenever a row Deleted from TFILE table, That curresponding row should be deleted from NEW_TAB.
i Tried Like....
create or replace
TRIGGER my_trigger
AFTER INSERT OR DELETE
ON tfile
FOR EACH ROW
DECLARE
V_FILE_ID NUMBER(8);
V_PROP_ID NUMBER(8);
V_DOC_ID NUMBER(8);
V_TEMP_FILE_ID NUMBER(8);
BEGIN
IF INSERTING THEN
SELECT B.DOC_ID,
B.PROP_ID,
A.FILE_ID
INTO V_DOC_ID,
V_PROP_ID,
V_FILE_ID
FROM (SELECT DOC_ID,
FILE_ID
FROM DOC_FILE
WHERE FILE_ID = (SELECT FILE_ID
FROM TFILE
WHERE FILE_ID = :NEW.FILE_ID)) A ,
DOC_OPPT B
WHERE B.DOC_ID = A.DOC_ID;
INSERT INTO NEW_TAB (SNO,FILE_ID,PROP_ID,DOC_ID)VALUES(CUST_COR_SEQ.NEXTVAL,V_FILE_ID,V_PROP_ID,V_DOC_ID);
END;
ELSIF DELETING THEN
DELETE FROM NEW_TAB WHERE FILE_ID = :OLD.FILE_ID;
END IF;
==================================================================
I am getting error like..
ORA-04091: table STARS.TFILE is mutating, trigger/function may not see it
ORA-06512: at "STARS.MY_TRIGGER", line 8
ORA-04088: error during execution of trigger 'STARS.MY_TRIGGER'
how to solve this....?
can anybody can explain solution for my problem with some good example please ?
thanksHi,
From Documentation
mutating table is a table that is currently being modified by an UPDATE, DELETE, or INSERT statement, or a table that might be updated by the effects of a DELETE CASCADE constraint.
*The session that issued the triggering statement cannot query or modify a mutating table*. This restriction prevents a trigger from seeing an inconsistent set of data.
This restriction applies to all triggers that use the FOR EACH ROW clause, and statement triggers that are fired as the result of a DELETE CASCADE
To avoid..an article by tom kyte.
http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551198119097816936
Hope it helps,
CKLP -
how to solve the mutation problem in triggers
Could you please guide me the steps to solve thisDon't select from the same table in the trigger.
(I'm pretty sure, it is not needed.)
Think about your logic again, in most cases the trigger is the wrong approach.
Tell us, what your business requirement is; what you are going to solve with a trigger. -
How to solve the ASInstance error
hello everyone,
when i install the BIEE11g, I always met a same mistake, that is 'ASInstance install error'. then I lookup the log file, it writes 'ASInstance error, Error in starting opmn server. operation aborted because of a system call failure or internal error'. could you tell me how to solve it?
if i choose to skip the error and continue to install, i could not to visit the http://localhost:7001/analytics and could not succee to run startall command in opmn.
notes: my os is win xp sp3 and database vision is 11.2.0.1.0 and rcu is 1.1.5.0
thank you very much.
regards,
phoenyhello everyone,
when i install the BIEE11g, I always met a same mistake, that is 'ASInstance install error'. then I lookup the log file, it writes 'ASInstance error, Error in starting opmn server. operation aborted because of a system call failure or internal error'. could you tell me how to solve it?
if i choose to skip the error and continue to install, i could not to visit the http://localhost:7001/analytics and could not succee to run startall command in opmn.
notes: my os is win xp sp3 and database vision is 11.2.0.1.0 and rcu is 1.1.5.0
thank you very much.
regards,
phoeny -
Hi,
How to catch or solve the 404 error in application.
Some time we are giving some file name but that file is not avialable at that time it will give 404 error. how to avoid this error.
If 404 error comes i want call some other file. Is it posible.
Thanks Advance.Yes, this is because IE 5.5 (?) and higher have this wacky "Show friendly HTTP error messages" setting. You can disable this by going to tools -> internet options -> advanced and unchecking "Show friendly HTTP error messages". However as the default IE setting has "Show friendly HTTP error messages" enabled this isn't a good solution.
I believe that if your error page is less than a certain size (in bytes) then IE defaults to it's own error page when "Show friendly HTTP error messages" are enabled. This size is something like 512 bytes or fewer in length.
So basically try making your error page larger (more than 512 bytes in size) and see if that works. -
how to solve the warning and severe error....................
[oracle@ip-********* Oracle11g_R2]$ emca -deconfig dbcontrol db -repos drop
STARTED EMCA at Mar 29, 2012 10:20:41 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database SID: testdb11g3
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: y
Mar 29, 2012 10:22:13 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u02/oracle/Oracle11g_R2/cfgtoollogs/emca/testdb11g3/emca_2012_03_29_22_20_40.log.
Mar 29, 2012 10:22:13 PM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be performed.
Mar 29, 2012 10:22:13 PM oracle.sysman.emcp.EMConfig perform
SEVERE: Listener is not up or database service is not registered with it. Start the Listener and register database service and run EM
Configuration Assistant again .
Refer to the log file at /u02/oracle/Oracle11g_R2/cfgtoollogs/emca/testdb11g3/emca_2012_03_29_22_20_40.log for more details.
Could not complete the configuration. Refer to the log file at
/u02/oracle/Oracle11g_R2/cfgtoollogs/emca/testdb11g3/emca_2012_03_29_22_20_40.log for more details.
[oracle@ip-******* Oracle11g_R2]$ cdtried but getting the same error.............
[oracle@ip-10-68-199-69 oracle]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 29-MAR-2012 23:37:21
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u02/oracle/Oracle11g_R2/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u02/oracle/Oracle11g_R2/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u02/oracle/Oracle11g_R2/diag/tnslsnr/ip-10-68-199-69/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 29-MAR-2012 23:37:21
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u02/oracle/Oracle11g_R2/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u02/oracle/Oracle11g_R2/diag/tnslsnr/ip-10-68-199-69/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@ip-10-68-199-69 oracle]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 29 23:37:34 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: sys/Ashwin
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Enter user-name: sys/Ashwin as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 402655344 bytes
Database Buffers 1191182336 bytes
Redo Buffers 7360512 bytes
Database mounted.
Database opened.
SQL> exit
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ip-10-68-199-69 oracle]$ emca -deconfig dbcontrol db -repos drop
STARTED EMCA at Mar 29, 2012 11:55:28 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database SID: testdb11g3
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: y
Mar 29, 2012 11:55:57 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u02/oracle/Oracle11g_R2/cfgtoollogs/emca/testdb11g3/emca_2012_03_29_23_55_27.log.
Mar 29, 2012 11:55:57 PM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be performed.
Mar 29, 2012 11:55:57 PM oracle.sysman.emcp.EMConfig perform
SEVERE: Listener is not up or database service is not registered with it. Start the Listener and register database service and run EM Configuration Assistant again .
Refer to the log file at /u02/oracle/Oracle11g_R2/cfgtoollogs/emca/testdb11g3/emca_2012_03_29_23_55_27.log for more details.
Could not complete the configuration. Refer to the log file at /u02/oracle/Oracle11g_R2/cfgtoollogs/emca/testdb11g3/emca_2012_03_29_23_55_27.log for more details. -
SOS:How to solve "internal fatal error:load.cpp line6345"?
hello,everybody. now i meet with a sharp problem in labview. when i try to save a .vi file in labview, sometimes an error information will happen which is "internal fatal error:"load.cpp", line6345". i have tried almost every way to solve this problem but falied at last.
Can you tell me how to solve this problem? thank u all!beryllan;
Let us know which version of LabVIEW you are using. After a quick search in here at the Discussion Forums, I found that problems with load.cpp were common in LabVIEW 6, (with special mentions to the Student Edition). If that's your case, try updating LabVIEW here.
Regards
Enrique
www.vartortech.com -
Understanding how to solve an SQL error
If any one has an idea of how to solve an error like this,kindly tell me what to do.Please.
Msg 8120, Level 16, State 1, Line 1
Column 'Members.Memb_contact' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.If any one has an idea of how to solve an error like this,kindly tell me what to do.Please.
Msg 8120, Level 16, State 1, Line 1
Column 'Members.Memb_contact' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Using the given info only thing we can suggest is to add Members.Memb_contact to the GROUP BY clause. But that may not give you the desired result. So unless you give us some sample data and explain what you want as output we may not be able to give you
the best solution.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
SAPMMC - can it be run standalone?
Since all of our Java systems have the SAPMMC snapin. In using this we noticed that we are able to add systems on other servers. From there we thought that perhaps we could install the snapin on our desktops and add all of our systems. That way we
-
Whenver u compile a JSP page it is internally converted into servlet.Where will this servlet be stored and by what name?
-
Trying to Load a BufferedImage from a PNG through JNI
Yes I realize that I can load it directly through Java and not go through JNI, but I need this to test correctly as my C code will aquire images without saving to Disk and I want Java code to manipulate the images without saving to disk. The image Im
-
OS:RH71 ORACLE RELEASE 8.1.7 what's the usage of function dbms_standard.client_ip_address of sys? THX.
-
DOH! Poor quality output after 4 days trying to perfect the DVD
Hi guys I have been trying to burn a 1hr 27min .avi file (700MB) for 4 days now. Ive tried a few ways but each time the DVD has poorer quality video than the original file. I tried: - opening .avi file in ImovieHD and then sharing it with iDVD (it re