Created
June 30, 2016 01:37
-
-
Save faogustavo/6ddf23faa7a306382528c4177e8fcc1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TRIGGER IF EXISTS `t_demissao`; | |
DELIMITER $$ | |
CREATE TRIGGER t_demissao BEFORE UPDATE | |
ON user | |
FOR EACH ROW | |
BEGIN | |
IF NEW.state = 'I' THEN | |
SET NEW.resignation_date = NOW(); | |
UPDATE equipament_has_user ehu | |
SET ehu.state = 'I' WHERE ehu.user_id = NEW.id; | |
END IF; | |
END$$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment