message_update.sql 315 B

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