Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: TRIGGER Example Jump to:  
Category: >> Oracle PL/SQL >> TRIGGER Example Bookmark and Share

<< 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;
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 58 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?