Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.66 KB | None | 0 0
  1. CREATE TABLE `notification_emails` (
  2.     `id` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
  3.     `recipient` INT(11) NOT NULL,
  4.     `subject` VARCHAR(50) NOT NULL,
  5.     `body` VARCHAR(255) NOT NULL
  6. );
  7.  
  8. DELIMITER $$
  9. CREATE TRIGGER `tr_notification_emails`
  10. AFTER INSERT ON `logs`
  11. FOR EACH ROW
  12. BEGIN
  13.     INSERT INTO `notification_emails`
  14.         (`recipient`, `subject`, `body`)
  15.     VALUES (
  16.         NEW.account_id,
  17.         CONCAT('Balance change for account: ', NEW.account_id),
  18.         CONCAT('On ', DATE_FORMAT(NOW(), '%b %d %Y at %r'), ' your balance was changed from ', ROUND(NEW.old_sum, 2), ' to ', ROUND(NEW.new_sum, 2), '.'));
  19. END $$
  20. DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement