issue_update.sql 448 B

12345678910111213141516
  1. DROP TRIGGER IF EXISTS `issue_update`;
  2. CREATE TRIGGER `issue_update`
  3. BEFORE UPDATE ON `issues`
  4. FOR EACH ROW BEGIN
  5. IF NEW.p_id IS NOT NULL AND NEW.name IN (
  6. SELECT name
  7. FROM issues
  8. WHERE p_id = NEW.p_id
  9. ) THEN
  10. SET @error = CONCAT('An issue with the name "',NEW.name,'"" already exists on the project "',project_name(NEW.p_id),'"');
  11. SIGNAL SQLSTATE '45000'
  12. SET MESSAGE_TEXT = @error;
  13. ELSE
  14. SET new.date_modified = NOW();
  15. END IF;
  16. END;