Created
June 2, 2015 19:03
-
-
Save markbalt/ddb4a48b4e685e7f2a1b to your computer and use it in GitHub Desktop.
Visitor MySQL Trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TRIGGER IF EXISTS `visitor_insert_t`; | |
DELIMITER ;; | |
CREATE TRIGGER `visitor_insert_t` AFTER INSERT ON `visitor` FOR EACH ROW BEGIN | |
IF NEW.arrival_date IS NOT NULL THEN | |
INSERT INTO `visit`( | |
`visitor_id`, | |
`location_id`, | |
`customer_id`, | |
`customer_name`, | |
`arrival_date`, | |
`depart_date`, | |
`expire_date`, | |
`has_arrived`, | |
`host_name`, | |
`host_email`, | |
`is_active`, | |
`purpose`, | |
`verified_date`, | |
`verified_by` | |
) | |
VALUES | |
( | |
NEW.id, | |
NEW.location_id, | |
NEW.customer_id, | |
NEW.customer_name, | |
NEW.arrival_date, | |
NEW.depart_date, | |
NEW.expire_date, | |
NEW.has_arrived, | |
NEW.host_name, | |
NEW.host_email, | |
NEW.is_active, | |
NEW.purpose, | |
NULL, | |
NULL | |
); | |
END | |
IF ; | |
END | |
;; | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment