Chapter Seven. Statement Level Triggers


7.1 SEQUENCE OF EVENTS

7.2 INSERT STATEMENT TRIGGER SYNTAX

7.3 STATEMENT LEVEL AGGREGATION

7.4 PROCESSING ROW CAPTURED DATA

This chapter begins with the same trigger that started Chapter 6, except this is a statement level trigger. We start with a TEMP table.

 
 DROP TABLE TEMP; CREATE TABLE temp (N NUMBER); 

Now create an ALTER-INSERT-STATEMENT trigger.

 
 CREATE OR REPLACE TRIGGER temp_ais AFTER INSERT ON TEMP BEGIN     dbms_output.put_line('executing temp_ais'); END; 

The following inserts have different results than the beginning of Chapter 6, which demonstrated a ROW trigger. We begin by inserting a single row.

 
 SQL> set feedback off SQL> INSERT INTO temp VALUES (1);          -- insert 1 row executing temp_ais SQL> INSERT INTO temp VALUES (1);          -- insert 1 row executing temp_ais SQL> INSERT INTO temp SELECT * FROM temp;  -- insert 2 rows executing temp_ais 

The INSERT statement fires once per SQL statement. For the last insert a row trigger would have to fire twice.



Programming Oracle Triggers and Stored Procedures
Programming Oracle Triggers and Stored Procedures (3rd Edition) (Prentice Hall PTR Oracle Series)
ISBN: 0130850330
EAN: 2147483647
Year: 2003
Pages: 111
Authors: Kevin Owens

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net