Last active
December 14, 2015 04:09
-
-
Save robjshaw/5026531 to your computer and use it in GitHub Desktop.
mysql trigger - action time: before / event: update
This file contains hidden or 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
| /* logging example */ | |
| BEGIN | |
| IF new.status <> old.status | |
| THEN | |
| INSERT INTO pstatus_log(dtCreated, statusOld, statusNew, fkid) | |
| VALUES (now(), old.status, new.status, new.fkid); | |
| END IF; | |
| END | |
| /* update DateTimeUpdated whenever the row is changed. */ | |
| BEGIN | |
| SET NEW.DateTimeUpdated = NOW(); | |
| END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment