This trigger giving mutation error? any body can tell why?

Hi All,
Could any body tell me where is the problem in my trigger.
my tables are.
1) EMP :- emp_id,emp_movement_status
2) EMPLOYEES_DAILY_MOVEMENT :- emp_id,transaction_time,transaction_remarks.
if i delete a entry from transactions_table, it has to take latest remarks from the maximum record after deletion of the record, then update EMP table accordingly.
trigger is:-
CREATE OR REPLACE TRIGGER change_employee_status AFTER INSERT OR UPDATE OR DELETE ON
employees_daily_movement FOR EACH ROW
DECLARE
local_remarks VARCHAR2(50);
BEGIN
IF DELETING THEN
SELECT transaction_remarks INTO local_remarks FROM employees_daily_movement WHERE
     transaction_id = (SELECT MAX(transaction_id) FROM employees_daily_movement WHERE
     emp_id = :old.emp_id );
/* here im expecting to take the TRANSACTION_REMARKS column value from employees_daily_movement after deleting the record which i wanted */
UPDATE emp SET emp_movement_status = local_remarks WHERE emp_id = :old.emp_id;
END IF;
END;
Thanks in advance

Hi Mr Rao,
You can handle muttating erros with following
1. Database version is oracle 9i and above, you can over come this problem for ever by using pragma autonomous_transaction.
2. Another way is, if you database version earlier to 9i then you can re-pharase this trigger by writting statement level trigger instead row level.
Cheers!!
Mahesh Ragineni

Similar Messages

  • Plesae any body can tell me some important real time FAQ's

    please any body can tell me some real time qutions they faced in interviews
    please it will help me a lot

    Hi,
    these are a few important questions
    ABAP Technical Interview Questions:
    1. What is the typical structure of an ABAP program?
    2. What are field symbols and field groups.? Have you used "component idx of structure" clause with field groups?
    3. What should be the approach for writing a BDC program?
    4. What is a batch input session?
    5. What is the alternative to batch input session?
    6. A situation: An ABAP program creates a batch input session. We need to submit the program and the batch session in background. How to do it?
    7. What is the difference between a pool table and a transparent table and how they are stored at the database level?
    8. What are the problems in processing batch input sessions? How is batch input process different from processing on line?
    9. What do you define in the domain and data element?
    10. What are the different types of data dictionary objects?
    11. How many types of tables exist and what are they in data dictionary?
    12. What is the step-by-step process to create a table in data dictionary?
    13. Can a transparent table exist in data dictionary but not in the database physically?
    14. What are the domains and data elements?
    15. Can you create a table with fields not referring to data elements?
    16. What is the advantage of structures? How do you use them in the ABAP programs?
    17. What does an extract statement do in the ABAP program?
    18. What is a collect statement? How is it different from append?
    19. What is open sql vs native sql?
    20. What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using it?
    21. What is the meaning of ABAP editor integrated with ABAP data dictionary?
    22. What are the events in ABAP language?
    23. What is an interactive report? What is the obvious diff of such report compared with classical type reports?
    24. What is a drill down report?
    25. How do you write a function module in SAP? Describe.
    26. What are the exceptions in function module?
    27. What is a function group?
    28. How are the date abd time field values stored in SAP?
    29. What are the fields in a BDC_Tab Table?
    30. Name a few data dictionary objects?
    31. What happens when a table is activated in DD?
    32. What is a check table and what is a value table?
    33. What are match codes? Describe?
    34. What transactions do you use for data analysis?
    35. What is table maintenance generator?
    36. What are ranges? What are number ranges?
    37. What are select options and what is the diff from parameters?
    38. How do you validate the selection criteria of a report? And how do you display initial values in a selection screen?
    39. What are selection texts?
    40. What is CTS and what do you know about it?
    41. When a program is created and need to be transported to prodn does selection texts always go with it? if not how do you make sure? Can you change the CTS entries? How do you do it?
    42. What is the client concept in SAP? What is the meaning of client independent?
    43. Are programs client dependent?
    44. Name a few system global variables you can use in ABAP programs?
    45. What are internal tables? How do you get the number of lines in an internal table? How to use a specific number occurs statement?
    46. How do you take care of performance issues in your ABAP programs?
    47. What are datasets?
    48. How to find the return code of a stmt in ABAP programs?
    49. What are interface/conversion programs in SAP?
    50. Have you used SAP supplied programs to load master data?
    2. Adapted from response by Maram Roja on Tuesday, June 15, 2004
    1. What are the techniques involved in using SAP supplied programs? Do you prefer to write your own programs to load master data? Why?
    2. What are logical databases? What are the advantages/disadvantages of logical databases?
    3. What specific statements do you using when writing a drill down report?
    4. What are different tools to report data in SAP? What all have you used?
    5. What are the advantages and disadvantages of ABAP query tool?
    6. What are the functional areas? User groups? How does ABAP query work in relation to these?
    7. Is a logical database a requirement/must to write an ABAP query?
    8. What is the structure of a BDC sessions.
    9. What are Change header/detail tables? Have you used them?
    10. What do you do when the system crashes in the middle of a BDC batch session?
    11. What do you do with errors in BDC batch sessions?
    12. How do you set up background jobs in SAP? What are the steps? What are the event driven batch jobs?
    13. Is it possible to run host command from SAP environment? How do you run?
    14. What kind of financial periods exist in SAP? What is the relevant table for that?
    15. Does SAP handle multiple currencies? Multiple languages?
    16. What is a currency factoring technique?
    17. How do you document ABAP programs? Do you use program documentation menu option?
    18. What is SAPscript and layout set?
    19. What are the ABAP commands that link to a layout set?
    20. What is output determination?
    reward if helpful
    vivekanand

  • Any body can tell the solution for these questions?

    1) If in case we r using OEM Grid controller,at that time database is running slow.so we can do the database is up , at the time what we have to do and how to clarify this problem ?
    2) we r using 4 databses and we have multiple segments of 4 databases...users can use heavly for all databases segments @ that time databases contain heavy burden, so this case arise what we have to do for reducing the burden for databases?
    Thanks, for giving sol. for these questions......

    No wonder, you didn't get answers to these questions, because this is not the right forum, and also the questions are very vague.
    user13096226 wrote:
    1) If in case we r using OEM Grid controller,at that time database is running slow.so we can do the database is up , at the time what we have to do and how to clarify this problem ?
    2) we r using 4 databses and we have multiple segments of 4 databases...users can use heavly for all databases segments @ that time databases contain heavy burden, so this case arise what we have to do for reducing the burden for databases?
    Thanks, for giving sol. for these questions......

  • Hi , any body can send real time problems they faced

    hi every body this is siva from banglore, any body can send the real time problems they faced in sap crm and how they solved if any body kindly send to my id : [email protected]

    hi Siva,
    All the issues in the forums are the real time issues
    YOu can just go through them .
    Also why do you need real time issues.
    If you have any issues post it here and some one can help you

  • I need Expert Decomposition of classes in Source Code for my reaserch purpose. Any body can help me in this regard?

    <blockquote>Locked by Moderator as a duplicate/re-post.
    Please continue the discussion in this thread: [tiki-view_forum_thread.php?comments_parentId=698286&forumId=1]
    Thanks - c</blockquote>
    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    I need Expert Decomposition of classes in Source Code of Firefox for my research purpose. Any body can help me in this regard?
    == This happened
    ==
    Not sure how often
    == Firefox version
    ==
    3.0.19
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19
    == Plugins installed
    ==
    *-Default Plug-in
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *6.0.12.1662
    *Office Plugin for Netscape Navigator
    *Google Update
    *Shockwave Flash 10.1 r53
    *Yahoo Application State Plugin version 1.0.0.7
    *Next Generation Java Plug-in 1.6.0_18 for Mozilla browsers
    *Adobe PDF Plug-In For Firefox and Netscape
    *DRM Netscape Network Object
    *Npdsplay dll
    *DRM Store Netscape Plugin

    Please let me tell you that I Expert Decomposition may be of any Version of Firefox or Thunder Bird.

  • Hi.. i've got problem with my iPhone 4s gsm factory unlocked it won't connect to a wifi. i tried to hold power and home button even reset the network setting but ended with i am not able even to turn the wifi on. does any body can help me out???

    hi..
    i've got problem with my iphone 4s gsm factory unlocked it won't connect to a wifi. i tried to hold the power and home button even reset the network setting but ended with i am not even can turn the wifi on. does any body can helpme?

    See this: http://support.apple.com/kb/TS1559
    If you carefully follow all of the instructions in this tip and none of them restore WiFi then your radio chip has failed and you need to get the phone replaced by Apple.

  • Hi  can any body please tell me how to open the .exe files in mac and why it is not supported with unarchiever app , also i am not able to run and dvd's in my mac its not accepting any cd's or dvd'd why do i need to do some settings for it ?

    Hi  can any body please tell me how to open the .exe files in mac and why it is not supported with unarchiever app , also i am not able to run and dvd's in my mac its not accepting any cd's or dvd'd why? do i need to do some pre defined  settings to run the cd's and dvd's ?

    A .exe file is a Windows executable. OS X does not run Windows programs. If you need to use .exe files then you will need to install Windows on your Mac:
    Windows on Intel Macs
    There are presently several alternatives for running Windows on Intel Macs.
    Install the Apple Boot Camp software.  Purchase Windows XP w/Service Pak2, Vista, or Windows 7.  Follow instructions in the Boot Camp documentation on installation of Boot Camp, creating Driver CD, and installing Windows.  Boot Camp enables you to boot the computer into OS X or Windows.
    Parallels Desktop for Mac and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  Parallels is software virtualization that enables running Windows concurrently with OS X.
    VM Fusionand Windows XP, Vista Business, Vista Ultimate, or Windows 7.  VM Fusion is software virtualization that enables running Windows concurrently with OS X.
    CrossOver which enables running many Windows applications without having to install Windows.  The Windows applications can run concurrently with OS X.
    VirtualBox is a new Open Source freeware virtual machine such as VM Fusion and Parallels that was developed by Solaris.  It is not as fully developed for the Mac as Parallels and VM Fusion.
    Note that Parallels and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc.  There are performance differences between dual-boot systems and virtualization.  The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system. See MacTech.com's Virtualization Benchmarking for comparisons of Boot Camp, Parallels, and VM Fusion. Boot Camp is only available with Leopard or Snow Leopard. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows.
    You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.

  • I used part of my name in my home network.  Now I understand this was stupid security error.  How can i change the name of my home wifi network, airport express?  Thanks.

    I used part of my name in my home network.  Now I understand this was stupid security error.  How can i change the name of my home wifi network, airport express?  Thanks.

    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click on the picture of the AirPort Express
    Click Edit in the smaller window that appears
    Click the Wireless tab at the top of the next window
    Edit the Wireless Network Name
    Keep it short.....maximum 10-12 characters or so. No blank spaces or punctuation marks in the name
    Click Update at the lower right of the window to save the new setting and wait a full minute for the AirPort to restart

  • TS2634 I have a very weak wifi signal, any body can help?

    I have a verry week wifi signal, any body can help?

    I have a verry week wifi signal, any body can help?

  • Iam facing a problem with JBorderless button please any body can solve my

    Dear Sir,
    Iam working on swing. for that iam using visualcafe tool. But for me iam facing a problem with JBorderlessbutton. I want set an image on that button for the button is displaying but the image is not displaying when i run the output. Iam using JDK1.4. Please any body can solve my problem If possible please send me a piece of code ill be thankful to you. Please.
    regards,
    surya

    Please supply some more information about the problem, e.g. a piece of code showing how the problem occurs.

  • Pls any one can tell about sql loader in linux?

    Pls any one can tell about sql loader in linux

    Hi,
    I don't think it matters which OS, sqlloader works the same for all OS. If you want more information, read first the manual: http://download.oracle.com/docs/cd/E11882_01/server.112/e16536/ldr_concepts.htm#i1005437
    Herald ten Dam
    http://htendam.wordpress.com

  • I need get the last iphone version any person can tell me how i can make it please

    i need get the last iphone version any person can tell me how can do it?

    The iPhone 3G can not run anything higher than 4.2.1. It is obsolete.

  • Hi there. Any one can tell me how erase cookies under the new safari Version 5.1 (7534.48.3)? Any one?

    Hi there. Any one can tell me how erase cookies under the new safari Version 5.1 (7534.48.3)? Any one?

    Click on the Safari menu then click on preferences the click the security icon.

  • Trigger giving an error

    I have a trigger defined as follows:
    create or replace trigger TR_MY_TRIGGER after
    delete or
    update on member
    begin
    end;
    At the end of the trigger I have a SELECT on the member table, the table on which this trigger is based. I get a mutating error: ORA-04091: table member is mutating
    How can I get around this problem? I have tried to put the select in a procedure, but that does not work either. I have also tried to put pragma autonomous_transaction in the trigger, but to no avail.
    Thanks
    Edited by: user447219 on Nov 2, 2012 10:27 AM
    Edited by: user447219 on Nov 2, 2012 10:28 AM

    user447219 wrote:
    At the end of the trigger I have a SELECT on the member table, the table on which this trigger is based. So when you select from the table do you know if you are getting the new or old values that are both present in a row level trigger? And which values do you want?
    I get an error message: An error occured.ORA-20505| Error in DML| p_rowid=
    You actually get a different error
    http://docs.oracle.com/cd/E11882_01/server.112/e17766/e2100.htm#sthref1926
    >
    ORA-04091: table string.string is mutating, trigger/function may not see it
    You are just hiding it and replacing it with that useless message to make troubleshooting and debug more difficult.
    How can I get around this problem? I have tried to put the select in a procedure, but that does not work either. I have also tried to put pragma autonomous_transaction in the trigger, but to no avail.The mutating table error is like the safety catch on a gun that makes it go click when you aim it at your toes and pull the trigger. You should not work around it, it is trying to tell you what you are trying to do is not reliable. Autonomous transactions are not a fix for this.
    You should read this and then find a different way to do whatever it is you need to do.
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/part_txn.htm#CHDJIGBH

  • URGENT : Trigger with Mutating Error

    Hi,
    I'm trying to write a trigger on a Table ROOM_BLOCK to update a value in table ROOM_OOI_OOS.
    As given below, which works perfectly.
    BEGIN
    IF INSERTING THEN
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    ELSIF UPDATING THEN
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    ELSE
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    END IF;
    END;
    But when I add a select statement. the trigger seems to fail with a mutating error ORA-04091
    and Error at Line which executes the statement immidiate ORA-04088.
    DECLARE
    stmt VARCHAR2(500);
    vcount INTEGER;
    BEGIN
    IF INSERTING THEN
    --INSERT INTO SHRUTI_TEST (DESCR) VALUES ('Inserting');
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    stmt := 'Select count(*) from ROOM_BLOCK ' ||
    ' WHERE ROOM_OOI_OOS_ID = ' || :NEW.ROOM_OOI_OOS_ID ||
    ' AND ROOM_NO = ''' || :NEW.ROOM_NO || ''' ';
    EXECUTE IMMEDIATE stmt INTO vcount;
    IF vcount = 1 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    END IF;
    ELSIF UPDATING THEN
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    ELSE
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    END IF;
    END;
    Please tell me how to solve this problem...
    Regards
    Mike.

    Thank you for your reply to my posting.
    I researched and used your recommendation. I was
    wondering if you can help me resolve the following two
    problems.
    Table kassa1 has NAME and AGE columns. Table Kassa2
    has one column Age.
    I have created the following trigger. It keeps
    raising a ORA-06519 : Active autonomous transaction
    detected and rolled back error.
    Create or replace trigger Name_Age_Row after insert or
    update on Kassa1
    For each row
    Declare
    Total_Age VARCHAR(8);
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
         Select SUM(Age) into Total_Age from Kassa1;
         insert into kassa2 values(Total_aAge);
    End;     
    The following trigger also generates ORA-00036:
    Maximum number of recursive SQL levels(50) exceeded
    error.
    Create or replace trigger Name_Age_Row after insert or
    update on Kassa1
    For each row
    Declare
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
         insert into kassa1 values('newname', 'newage');
    End;     

Maybe you are looking for