Oracle trigger notes

Source: Internet
Author: User
-Oracle trigger note-the execution sequence is: #1. Execute the before statement-Level Trigger. For each row affected by the statement: -- #2. Execute the Level Trigger and execute the DML statement-

-Oracle trigger note-the execution sequence is: #1. Execute the before statement-Level Trigger. For each row affected by the statement: -- #2. Execute the Level Trigger and execute the DML statement-

Create or replace trigger emp
-- Before indicates the trigger before the operation
-- After indicates the trigger after the operation

-- Up to 12 triggers can be created for each table
-- Before inset
-- Before insert for each row
-- After insert
-- After insert for each row

-- Before uPdate
-- Before uPdate for each row
-- After uPdate
-- After uPdate for each row

-- Before uPdate
-- Before uPdate for each row
-- After uPdate
-- After uPdate for each row

-- The execution order is: #1. Execute the before statement-Level Trigger, for each row affected by the statement:
-- #2. Execute the Level Trigger and execute the DML statement
-- Execute the after row-Level Trigger
-- #3. Execute an after statement-Level Trigger

Before delete on aaa -- trigger for the aaa table before the delete operation

For each row -- execute the trigger once for each row of the table. If this option is not available, the entire table is executed only once.
Declare

Begin

/* If you insert an aaa table, the following error occurs in row 1st:
ORA-04091: The Table QUERY. AAA has changed and the trigger/function cannot read it
ORA-06512: In "QUERY. EMP", line 4 (QUERY represents user, line represents number of rows, EMP represents trigger name)
ORA-04088: An error occurred while executing the trigger 'query. emp */

/* Insert the data before modification to the aaa_tmp log table for supervision */
Insert into aaa_tmp (AID, ANAME, PRICE)

Values (: old. AID,: old. ANAME,: old. PRICE); --: old indicates the original data,
--: New indicates the new data to be inserted.
End emp;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.