Section 9
Section 9
Procedure
• Example:
CALL get_employees_by_age(30);
Procedure
• Example:
DROP PROCEDURE get_employees_by_age;
Trigger
• Types of trigger
– BEFORE trigger: This trigger is activated before an INSERT,
UPDATE, or DELETE event occurs on a table. A BEFORE
trigger allows you to modify data or perform checks before the
actual change takes place.
– AFTER trigger: This trigger is activated after an INSERT,
UPDATE, or DELETE event has occurred on a table. An AFTER
trigger allows you to perform actions after the data change has
been made.
Trigger
DELIMITER $$
CREATE TRIGGER trigger_name
{BEFORE | AFTER} {INSERT | UPDATE | DELETE} ON table_name
FOR EACH ROW
BEGIN
Statement;
END //
DELIMITER ;
Trigger
• Example: