Definition Row-level triggers fires once for each row affected by the triggering event such as INSERT, UPDATE, or DELETE. Row-level triggers are useful for data-related activities such as data auditing and data validation. Syntax To create a new row-level trigger, you use the CREATE TRIGGER statement with the FOR EACH ROW clause. CREATE OR REPLACE TRIGGER trigger_name BEFORE | AFTER INSERT OR DELETE OR UPDATE OF column1, column2, … ON table_name Color Meaning FOR EACH ROW REFERENCING OLD AS old_name Blue Necessary NEW AS new_name Red Type WHEN (condition) Orange Optional DECLARE … BEGIN … END; / Characteristics Check if the current event is INSERT, UPDATE, and DELETE using the INSERTING or DELETING or UPDATING. A BEFORE row-level trigger can modify the new column values, but an AFTER row-level trigger cannot. You can access the old and new column values using the following syntax. :OLD.column_name :NEW.column_name Example Creating a customers table. This column contains the credit limit of a customer Example Creating Trigger for customer_credit_limit When a new credit is greater or equals than 1000
If a new credit is greater or
equals than the double of old credit it doesn't be updated in the table Example Testing trigger Inserting data for the example