DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`moving_delete`(vExpeditionFk INT)
BEGIN
	
	/* Elimina un movimiento
	 * 
	 * @param vExpeditionFk Identificador de srt.expedition
	 * 
	 */
	
	INSERT INTO srt.movingLog(expeditionFk, bufferFromFk, bufferToFk, stateFk, isColliding, movingFk, `action`)
		SELECT expeditionFk, bufferFromFk, bufferToFk, stateFk, isColliding, id, 'DELETE' 
			FROM srt.moving 
			WHERE expeditionFk = vExpeditionFk;
		
	DELETE FROM srt.moving 
		WHERE expeditionFk = vExpeditionFk;
	
END$$
DELIMITER ;
