473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help: Trigger -Not able to delete data from trigger table.

2
Hello,

I'm facing oracle trigger problem. Anyone can help or advise how to resolve it?

Below are the explaination on my problem

I've created a trigger for my program. When there is a new data insert into table moto_pvs_pulse_daily_yield_tmp, my program will checking and copy the data by each row and insert into table mt_pulse_daily_yield_tmp which is in other instance.

After I success insert into table mt_pulse_daily_yield_tmp, I need to delete the data in the original table (moto_pvs_pulse_daily_yield_tmp), but I'm getting the error as below:

ORA-04091: table MOTOPVS_OWN.MOTO_PVS_PULSE_DAILY_YIELD_TMP is mutating, trigger/function may not see it


Here are my code:

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE TRIGGER moto_pvs_pulse_daily_yield_trg after INSERT ON moto_pvs_pulse_daily_yield_tmp FOR EACH ROW
  2. DECLARE
  3.      v_sql_error        moto_pvs_db_error.ora_error%TYPE;
  4.  
  5. BEGIN
  6.         IF :NEW.board_yield >= 0 THEN
  7.             insert into mt_pulse_daily_yield_tmp --MotoTrak Table
  8.             (factory_id,line_id,board_item_number,manufactory_day,panel_yield,board_yield,insert_datetime)
  9. values
  10. (:NEW.factory_id,:NEW.line_id,:NEW.board_item_number,:NEW.manufactory_day,:NEW.panel_yield,:NEW.board_yield,:NEW.insert_datetime);
  11.  
  12. DELETE MOTO_PVS_PULSE_DAILY_YIELD_TMP;
  13.  
  14. ELSE
  15.         INSERT INTO MOTO_PVS_DB_ERROR(FROM_PROCEDURE,ERROR_DATE,MESSAGE)
  16. VALUES
  17. ( 'MOTO_PVS_PULSE_DAILY_YIELD_TRG', SYSDATE , 'BOARD YIELD VALUE FOR FACTORY_ID: ('||:NEW.factory_id||') AND LINE_ID: ('||:NEW.line_id||') MUST BE POSITIVE');
  18.  
  19. END IF;   
  20.  
  21. EXCEPTION
  22.   WHEN OTHERS THEN
  23.     v_sql_error := SQLERRM;
  24.     INSERT INTO moto_pvs_db_error (from_procedure, error_date, message, ora_error)
  25.     VALUES ('MOTO_PVS_PULSE_DAILY_YIELD_TRG', SYSDATE, 'ERROR DURING UPLOADING YIELD DATA', v_sql_error);
  26.  
  27. END moto_pvs_pulse_daily_yield_trg;
/


P/S: I believed this line is "DELETE MOTO_PVS_PULSE_DAILY_YIELD_TMP;" is caused the problem. but how to resolve it? Is really highly appreciate if anyone can advise me. Thank you very much.
Sep 3 '07 #1
4 2322
amitpatel66
2,367 Expert 2GB
This Error is caused because the TRIGGER is trying to perform DML operation on the table on which it is based upon.
Sep 3 '07 #2
amitpatel66
2,367 Expert 2GB
Check out for solution Here
Sep 3 '07 #3
Alexis
2
Hi,

Thanks for your quick response. I had read through the solution url you provide, but still not really understand how to resolve the problem. Can I delete the data for it own table in the trigger itself?

Thanks
Sep 4 '07 #4
amitpatel66
2,367 Expert 2GB
Follow the below steps:

1. Create a Package Spec that will have two Arrays (one will hold the ROWID of the newly inserted value and the second one is to reset the first one else u can also use empty constructor)

2. Create a BEFORE INSERT statement LEVEL TRIGGER ON MOTOPVS_OWN.MOTO_PVS_PULSE_DAILY_YIELD_TMP to bring the Package to its consistent state and initialisze the NULL Varray.

3. Create a After INSERT ROWLEVEL on MOTOPVS_OWN.MOTO_PVS_PULSE_DAILY_YIELD_TMP to get the ROWID of the newly inserted row.

4. Create a AFTER INSERT statement level on MOTOPVS_OWN.MOTO_PVS_PULSE_DAILY_YIELD_TMP and use the ROWID in the package VARRAY to insert that row in to mt_pulse_daily_yield_tmp table.
Then delete the Row in MOTOPVS_OWN.MOTO_PVS_PULSE_DAILY_YIELD_TMP after it is inserted in to mt_pulse_daily_yield_tmp table.

This should work. Let me know if it does not.
Sep 5 '07 #5

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

Similar topics

6
by: Edward King | last post by:
Hi! I am trying to achieve the following: I have a number of help pages (in the format help_nn.php where nn=helpid). I want to be able to open a particular help page by calling the function...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
4
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to...
2
by: clintonG | last post by:
Is there a document that explains the difference between the Visual Studio .NET 2003 Combined Help Collection and the MSDN Library for Visual Studio .NET 2003 or does someone have comments...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
6
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect...
0
by: tbatwork828 | last post by:
If you were like me trying to figure out how to launch context sensitive help topic by the context id, here is the link: http://weblogs.asp.net/kencox/archive/2004/09/12/228349.aspx and if...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
5
by: Steve Teeples | last post by:
Can someone point me to a document that clearly identifies the steps of creating a good help system for an application? I have a test tool that I'd like to add help to so that others will know how...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.