Wednesday, August 7, 2019

FOR EACH ROW in Triggers

CREATE OR REPLACE TRIGGER myTrigger
                                                           AFTER INSERT ON company
                                                           REFERENCING NEW AS new_org
                                                           FOR EACH ROW
                                                           WHEN (new_org.product_id <>1)
BEGIN
                    UPDATE product_audit
                            SET num_rows =num_rows+1
                     WHERE product_id =:new_org.product_id;
 
                      IF (SQL%NOTFOUND)
                      THEN
                     
                       INSERT INTO product_audit
                       VALUES (:new_org.product_id,1);
       
                      END IF;
END;

How many types of database triggers can be specified on a table? What are they?
Insert                Update              Delete

Before Row                            o.k.                    o.k.                    o.k.

After Row                              o.k.                    o.k.                     o.k.

Before Statement                   o.k.                    o.k.                     o.k.

After Statement                     o.k.                    o.k.                      o.k.

If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.

If WHEN clause is specified, the trigger fires according to the returned Boolean value.

No comments:

Post a Comment

AME (Approval Management Engine)

AME (Approval Management Engine) : AME Stands for Oracle Approval Management Engine. AME is a self service web application that enables...