salix/db/routines/srt/triggers/moving_afterInsert.sql

23 lines
671 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-01-25 16:33:54 +00:00
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`moving_afterInsert`
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 ;