Solution for the mutation of table of error when using triggers

Hello

Could you please give the solution for the error table mutation during the use of triggers. I'll give you the simple scenario here,

I created a trigger on the employees table, whenever all DML operations takes place in the employees table, it must run the trigger body. I intentionally used also of the employees in the body of the trigger table. Please give me the solution.

Triggering factor:

create or replace trigger test_trigger

before you insert or update or delete employees

for each line

declare

an employees.first_name%type;

Start

Select first_name from people where job_id = "AD_PRES";

end;

DML statement:

Update employees set salary = 20000 where job_id = "AD_PRES" (I run this query)

Error message:

ORA-04091: table HR. Is the transfer of EMPLOYEES, the function of triggering/can not see

ORA-06512: at "HR. TEST_TRIGGER', line 4

ORA-04088: error during execution of trigger ' HR. TEST_TRIGGER'

Can anyone tell, in what other scenarios, we get this error or recursive table mutation?

Thanks in advance

Hello

When you create a trigger on a table, you cannot edit/query this table the trigger is not completed.

You can use

(1) transaction of Pragma autonomous

(2) instead of row-level trigger, you have statement-level trigger

(3) to 11 g, try with COMPOSITE trigger

Try below to avoid it (a solution):

create or replace trigger test_trigger

before you insert or update or delete employees

for each line

declare

PRAGMA AUTONOMOUS_TRANSACTION;

an employees.first_name%type;

Start

Select first_name from people where job_id = "AD_PRES";

COMMIT;

end;

Tags: Database

Similar Questions

  • I searched for a solution for the problem I was on Win 7 Pro Service Pack 1 in the links on an open Adobe Acrobat file will not open in my browser Firefox 33.0.2. The error I get is "Acrobat could not run the web browser.  Unknown error. (123).

    I want a solution for the problem I was on Win 7 Pro Service Pack 1 in the links on an open Adobe Acrobat Pro 10.1.12 file will not open in my browser Firefox 33.0.2. The error I get is "Acrobat could not run the web browser.  Unknown error. (123).

    You can try a repair of your Acrobat installation. Maybe, at least it's a start toward a solution.

  • I found the solution for the problem of sound-acpi with Satellite P100-219

    Hello

    I found the solution for the problem of sound-acpi with Toshiba P100 (it works with P100-219 at least). I can provide the source modified and compiled table DSDT, but I would like to know if it is possible to get these changes in the next update of the BIOS?

    See you soon,.
    MIK

    Hi Mik

    As you know that it is not possible to find info on the next BIOS, especially if you want to have some information about the Linux operating system. Just wait and see if some forum users pointed out something on the subject.

  • Does anyone have a solution for the use of Bible Illustrator 3.0 MS8 and MS7

    Original title: program programs Application Applications compatibility.

    Does anyone have a solution for the use of Bible Illustrator 3.0 MS8 and MS7

    What are the requirements of system for this program?

    What version of Windows it says on the package, it was designed for?

    If its designed for an earlier version of Windows such as Windows 95 or Windows 98 or XP, then it is probably incompatible with Windows 8.

    If the product packaging indicates anything in the 1990s OR early 2000s, I am afraid that this is not something that is guaranteed to work with Windows 8.

    You can try the following average time.

    Point to the installation files where they are.

    Right-click on the configuration file, and then click "troubleshoot compatibility".

    Wait, it detects the problem.

    Click on the option "worked in an earlier version of Windows.

    Select Windows 7 RTM or better Windows Vista SP2

    Click next

    Click Start the program, wait, it installs

    When the installation is complete, click Finish and save the settings.

  • How can I write the trigger for the global temporary Table

    Hi Grus,
    How can I write the trigger for the global temporary Table.

    I created the TWG with trigger using the script below.


    CREATE A GLOBAL_TEMP GLOBAL TEMPORARY TABLE
    (
    EMP_C_NAME VARCHAR2 (20 BYTE)
    )
    ON COMMIT PRESERVE ROWS;


    CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
    BEFORE DELETE, UPDATE OR INSERT
    ON GLOBAL_TEMP
    REFERRING AGAIN AS NINE OLD AND OLD
    FOR EACH LINE
    BEGIN
    INSERT INTO VALUES EMPNAME (: OLD.) EMP_C_NAME);
    END;
    /


    trigger was created successfully, but her would not insert EMPNAME Table...

    Please guide if mistaken or not? If not wanting to give a correct syntax with example


    Thanks in advance,
    Arun M M
    BEGIN
    INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
    END;
    
    you are referencing old value in insert stmt.
    
    BEGIN
    INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
    END;
    

    then run your app, it works very well...

    CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
    (
    EMP_C_NAME VARCHAR2(20 BYTE)
    )
    ON COMMIT PRESERVE ROWS;
    
    CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
    BEFORE DELETE OR UPDATE OR INSERT
    ON GLOBAL_TEMP
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
    dbms_output.put_line(:OLD.EMP_C_NAME||'yahoo');
    INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
    dbms_output.put_line(:OLD.EMP_C_NAME);
    END;
    /
    
    create table EMPNAME as select * from GLOBAL_TEMP where 1=2
    
    insert into GLOBAL_TEMP values('fgfdgd');
    commit;
    select * from GLOBAL_TEMP;
    select * from EMPNAME;
    
    output:
    1 rows inserted
    commit succeeded.
    EMP_C_NAME
    --------------------
    fgfdgd               
    
    1 rows selected
    
    EMP_C_NAME
    --------------------
    fgfdgd               
    
    1 rows selected
    

    He got Arun

    Published by: OraclePLSQL on December 28, 2010 18:07

  • FOR the UPDATE OF table.field

    Why the following does it
    create table division (code varchar2(2) primary key, div_desc varchar2(20));
    
    insert into division values ('01', 'Ninja assassins');
    insert into division values ('02', 'Working for the man');
    
    
    create table employees (tk number, first_name varchar2(10), last_name varchar2(10), code varchar2(2) references division(code));
    
    insert into employees values (1, 'Chuck', 'Smith', '01');
    insert into employees values (2, 'John',  'Smith', '02');
    
    DECLARE
    
      CURSOR my_csr IS
        Select e.tk, e.first_name, e.last_name
        From employees e, division d
        Where e.code = d.code
          and e.code = '01'
          and e.last_name = 'Smith'
        For update;
        
        cnt_updated NUMBER;
    
    BEGIN
    
      cnt_updated := 0; 
    
      FOR my_row IN my_csr
      LOOP
    
        Update employees
        Set last_name = 'Forbes'
        Where current of my_csr;
        
        cnt_updated := cnt_updated + SQL%ROWCOUNT;
        dbms_output.put_line('You updated '||cnt_updated||' records');
    
      END LOOP;
    END;
    but just add the clause "for update" allows to make the point?
    DECLARE
    
      CURSOR my_csr IS
        Select e.tk, e.first_name, e.last_name
        From employees e, division d
        Where e.code = d.code
          and e.code = '01'
          and e.last_name = 'Smith'
        For update *of e.tk*;
    We discovered this recently, and fellow developers are wondering "why?" Is there a reason documented, or is - just how it is?

    Thank you
    -= Chuck

    of 'of the user to the database PL/SQL Oracle® reference Guide. "
    "10g Release 2 (10.2):
    "During the interrogation of several tables, you can use the FOR UPDATE clause to limit the line blocking to specific tables. Rows in a table are locked unless done FOR UPDATE OF clause refers to a column in the table. For example, the following query locks the rows in the employees table, but not in the departments table:

    DECLARE
    CURSOR c1 IS SELECT last_name, department_name FROM employees, departments
    WHERE employees.department_id = departments.department_id
    AND job_id = "SA_MAN."
    FOR the UPDATE OF treatment; »

    a little demo:

    SQL> select * from v$version;
    
    BANNER
    -------------------------------------------------------------------------
    
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    
      1   DECLARE
      2     CURSOR my_csr IS
      3       Select e.tk, e.first_name, e.last_name, e.rowid
      4       From employees_t e, division d
      5       Where e.code = d.code
      6         and e.code = '01'
      7         and e.last_name = 'Smith'
      8       For update of e.tk;
      9       cnt_updated NUMBER;
     10   BEGIN
     11     cnt_updated := 0;
     12     FOR my_row IN my_csr
     13     LOOP
     14       Update employees_t
     15       Set last_name = 'Forbes'
     16       Where current of my_csr;
     17       cnt_updated := cnt_updated + SQL%ROWCOUNT;
     18       dbms_output.put_line('You updated '||cnt_updated||' records');
     19     END LOOP;
     20*  END;
    SQL> /
    You updated 1 records
    
    PL/SQL procedure successfully completed.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1   DECLARE
      2     CURSOR my_csr IS
      3       Select e.tk, e.first_name, e.last_name, e.rowid
      4       From employees_t e, division d
      5       Where e.code = d.code
      6         and e.code = '01'
      7         and e.last_name = 'Smith'
      8       For update;-- of e.tk;
      9       cnt_updated NUMBER;
     10   BEGIN
     11     cnt_updated := 0;
     12     FOR my_row IN my_csr
     13     LOOP
     14       Update employees_t
     15       Set last_name = 'Forbes'
     16       Where current of my_csr;
     17       cnt_updated := cnt_updated + SQL%ROWCOUNT;
     18       dbms_output.put_line('You updated '||cnt_updated||' records');
     19     END LOOP;
     20*  END;
    SQL> /
    
    PL/SQL procedure successfully completed.
    

    Amiel

  • I installed photoshop elements only on 2 PC for the third IE maximum PC already in use. What should do?

    Installed photoshop elements only on two PC. for the third it is said maximum number used what to do?

    You can also check "Activation limit reached" or "connection error impossible ' with Adobe applications

    Concerning

    Hervé Khare

  • Receive the 25 (Null) error when using Flightsimulator FSX

    Receive the 25 (Null) error when using Flightsimulator FSX

    Hello

    Try to open the it to start - all programs - Games - Games Explorer, and then clicking the icon FSX.

    A disk error of 25 means that the program cannot read your disk reading.  Either the disc is scratch, dirty or defective.  If you need another drive, or you can try it on another computer. The message of Visual elements of Vista is not serious.  Vista will automatically your screen to a basic compatible mode when the application is launched.  However, it seems that your game is a failure due to the disk error and not the Vista display problem. Try to clean the disc and see if that helps.

    Last resort, it seems you'd have to do a complete uninstall and reinstall FSX.

    Cheers!

  • I signed up for the 10 free stock images, and when I try to download them, save them to the desktop isn't an option.  What should I do?  I need to get rid of the tattoo.

    I signed up for the 10 free stock images, and when I try to download them, save them to the desktop isn't an option.  What should I do?  I need to get rid of the tattoo.

    Follow the n steps these screenshots: I downloaded my 10 free images and they all have the Adobe watermark on them, so I can't use them. Why do they have a watermark on them?

  • How can I update my credit card information to pay for the next tranche of creative cloud when it tells me that I have "Creative Cloud Free Membership" so without possibility to update a credit card - despite my payment for a slice of 1 year in January 20

    How can I update my credit card information to pay for the next tranche of creative cloud when the screen tells me that I have "Creative Cloud Free Membership" so without possibility to update a credit card - despite my payment for a slice of 1 year in January 2015?

    Hi kanikas100,

    Using my old Email to open a session allowed me to see my current subscription and I was able to update my credit card.   Thank you very much!

  • "The server has encountered an error" when you want to send a message with the form.

    Hello

    "The server has encountered an error" when you want to send a message with the form.

    With the businesscatalyst site, the message is well received by the recipient as the site FTP host, the previous message is displayed.

    What code do I add and where?

    In advance, thank you.

    Please, answer in french!

    Hello ScratchMaster,

    Please see the link below, I'm sure that you will find it useful.

    https://forums.Adobe.com/docs/doc-3581

    Kind regards

    Vivek

  • Hello, I had a problem with my band. It does not really suppose he numbered scenes everything in order and he has so far in until I missed an and changed for the good order. But now when I go back to where I left and I have create a new scene

    Hello, I had a problem with my band. It does not really suppose he numbered scenes everything in order and he has so far in until I missed an and changed for the good order. But now when I go back to where I left and I have create a new scene number come up as * it and I need to change personally. is their any way I can change it to order normally?

    Hello

    You can manage this through the "Manage scene numbers" option in the menu 'Production '.

    There is a setting in this dialog box to assign scene numbers automatically to the new scenes.

  • My contact form is saying "the server has encountered an error" when submitted

    My contact form is saying "the server has encountered an error" when submitted. It has worked very well and I use the same form on another site that works well. Can anyone help? The website link is: http://www.lifeclinics.com/contact-us.html

    Hello

    Please check the following threads,

    The server encounters an error, don't know what to do

    Detailed Contact form error

    Let me know if you have any question.

  • I have CS6 Production Premium and speed category, I installed and when I try to run the program I need to sign up for the cloud.  I just want to use my version can help you or seated, me?

    I have CS6 Production Premium and speed category, I installed and when I try to run the program I need to sign up for the cloud.  I just want to use my version can help you or seated, me?

    I have stick thread regarding the CS6 and Cloud Creative Re: What's up with Adobe Application Manager CS6?

    and another, if you are confused enough, perhaps another angle my old CS6 now asking me to connect to the cloud

    and maybe he has your response a bit clearer how we prevent cloud creative resume my perpetual license CS6?

  • dbms_crypto - avoid error when using different key in lower environment

    Hello Experts,

    We use Oracle 11.2.0.2. We intend to implement dbms_crypto to encrypt some columns. Clone us the production data at the lower environment (DEV, QC).

    The lowest environments, we do not want to obtain the sensitive data from production and do not plan to use the same key. Instead of getting an error when using different keys, is it possible to get a different set of results.

    In other words, we want the implementation will be same in environments but use a different key in lower environment and obtain different results (or garbage).

    Any suggestions would be greatly appreciated.

    The test of this logic, I get following error when using the different keys to decrypt. It works fine if I use the same key.
    Error on line 1
    ORA-28817: PL/SQL function has returned an error.
    ORA-06512: at "SYS." DBMS_CRYPTO_FFI', line 67
    ORA-06512: at "SYS." DBMS_CRYPTO", line 44
    ORA-06512: at line 19
    DECLARE
      l_credit_card_no    VARCHAR2(19) := '1234 5678 9012 3456';
      l_ccn_raw           RAW(128) := UTL_RAW.cast_to_raw(l_credit_card_no);
     
     l_key               RAW(128) := UTL_RAW.cast_to_raw('abcdefgh');
       l2_key               RAW(128) := UTL_RAW.cast_to_raw('12345678');
    
      l_encrypted_raw     RAW(2048);
      l_decrypted_raw     RAW(2048);
    BEGIN
      DBMS_OUTPUT.put_line('Original  : ' || l_credit_card_no);
    
      l_encrypted_raw := DBMS_CRYPTO.encrypt(src => l_ccn_raw, 
                                             typ => DBMS_CRYPTO.des_cbc_pkcs5, 
                                             key => l_key);
    
      DBMS_OUTPUT.put_line('Encrypted : ' || RAWTOHEX(UTL_RAW.cast_to_raw(l_encrypted_raw)));
    
      l_decrypted_raw := DBMS_CRYPTO.decrypt(src => l_encrypted_raw, 
                                             typ => DBMS_CRYPTO.des_cbc_pkcs5, 
                                             key => l2_key); --**Using different key to decrypt
    
      DBMS_OUTPUT.put_line('Decrypted : ' || UTL_RAW.cast_to_varchar2(l_decrypted_raw));
    END;
    Thank you.

    In general, you can't get different results in different environments, no.

    Of course, you could write your routine to decrypt so that it intercepts it and returns a random string of RAW.

    However, this is not normally the way people go on hiding sensitive data in environments below. It would be much more common to use a tool that is designed for this tool. For example, Oracle has a Pack of masking of data for Enterprise Manager that allows to replace sensitive data with false, but realistic data as part of the updating of the environments below. There are also data from third-party tools like masqueur datamasking.

    Justin

Maybe you are looking for