project_update.sql 301 B

1234567891011
  1. DROP TRIGGER IF EXISTS `project_update`;
  2. CREATE TRIGGER `project_update`
  3. BEFORE UPDATE ON `projects`
  4. FOR EACH ROW BEGIN
  5. IF new.name REGEXP '^[[:alpha:]]' THEN
  6. SET new.date_modified = NOW();
  7. ELSE
  8. SIGNAL SQLSTATE '45000'
  9. SET MESSAGE_TEXT = 'Project names must start with a letter';
  10. END IF;
  11. END;