DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`moving_AI` AFTER INSERT ON `moving` FOR EACH ROW BEGIN INSERT INTO srt.movingLog(movingFk, expeditionFk, bufferFromFk, bufferToFk, stateFk, isColliding, `action`) VALUES(NEW.id, NEW.expeditionFk, NEW.bufferFromFk, NEW.bufferToFk, NEW.stateFk, NEW.isColliding, 'NEW2'); DELETE FROM srt.movingLast; INSERT INTO srt.movingLast (id, expeditionFk, bufferFromFk, bufferToFk) VALUES(NEW.id, NEW.expeditionFk, NEW.bufferFromFk, NEW.bufferToFk); IF srt.buffer_isFull(NEW.bufferToFk) THEN CALL srt.buffer_setStateType(NEW.bufferToFk, 'FULL',NULL); END IF; END$$ DELIMITER ;