May 2020
Beginner
564 pages
14h 9m
English
If you want to run multiple statements inside your trigger, you will need to use DELIMITER statements around your SQL statements, much the same way you use them in a stored procedure. The syntax for this is as follows:
DELIMITER $$ CREATE TRIGGER before_allstar_update BEFORE UPDATE ON allstarfull_copy FOR EACH ROW BEGIN IF OLD.playerid <> NEW.playerid THEN INSERT INTO allstarfull_audit SET actiontype = 'update', playerid = OLD.playerid, yearid = OLD.yearid, gamenum = OLD.gamenum, gameid = OLD.gameid, teamid = OLD.teamid, lgid = OLD.lgid, gp = OLD.gp, startingpos = OLD.startingpos, changedate = NOW(); END IF;END$$DELIMITER ;
The preceding code will only insert into the allstarfull_audit ...
Read now
Unlock full access