message_insert.sql 319 B

12345678910
  1. DROP TRIGGER IF EXISTS `message_insert`;
  2. CREATE TRIGGER `message_insert` BEFORE INSERT ON `messages`
  3. FOR EACH ROW BEGIN
  4. IF new.i_id IS NOT NULL AND new.p_id IS NOT NULL THEN
  5. SIGNAL SQLSTATE '45000'
  6. SET MESSAGE_TEXT = 'Messages can only be related to one thing';
  7. ELSE
  8. SET new.date_modified = NOW();
  9. END IF;
  10. END;