Quick Search:
 
 Oracle PL/SQL: TRIGGER Example Jump to:  
Category: >> Oracle PL/SQL >> TRIGGER Example  

<< lastnext >>

Snippet Name: TRIGGER Example

Description: A trigger is executed implicitly whenever the triggering event happens. The triggering event is either a INSERT, DELETE, or UPDATE command. The timing can be either BEFORE or AFTER.

Also see:
» Trigger sample
» Create trigger in Oracle

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 06th, 2009

-- this example is based on the following two tables:
 
CREATE TABLE T4 (a INTEGER, b CHAR(10));
CREATE TABLE T5 (c CHAR(10), d INTEGER);
 
-- create a trigger that may insert a tuple into 
-- T5 when a tuple is inserted into T4. Specifically, 
-- the trigger checks whether the new tuple has a first 
-- component 10 or less, and if so inserts the reverse 
-- tuple into T5:
 
CREATE TRIGGER trig1
    AFTER INSERT ON T4
    REFERENCING NEW AS newRow
    FOR EACH ROW
    WHEN (newRow.a <= 10)
    BEGIN
        INSERT INTO T5 VALUES(:newRow.b, :newRow.a);
    END trig1;
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org