Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

Chapter 14: Writing and Executing SQL Ro... > Executing Modules as Stored Procedur... - Pg. 300

300 Chapter 14: Writing and Executing SQL Routines and Modulesx CREATE TRIGGER trigger_name when_to_execute type_of_event ON table_name row_or_table_specifier EXECUTE PROCEDURE procedure_or_function_name The when_to_execute value is either BEFORE or AFTER, the type of event is INSERT, MODIFY, or DELETE, and the row_or_table_specifier is either FOR EACH ROW or FOR EACH STATEMENT. For example, to trigger the procedure that updates the sale_to- tal_amt in the sale table whenever a volume is sold, someone at the rare book store could use CREATE TRIGGER t_update_total AFTER UPDATE ON volume FOR EACH STATEMENT EXECUTE PROCEDURE p_update_total; The trigger will then execute automatically whenever an up- date is performed on the volume table.