DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_outAll`(vBufferFk INT)
BEGIN
	
	/**
	 * Envia todas las expediciones al mismo buffer
	 *
	 * @param vBufferFk Identificador de vn.buffer
	 * 
	 */
	
	INSERT INTO srt.moving (expeditionFk, bufferFromFk, bufferToFk)
		SELECT e.id, e.bufferFk, vBufferFk
			FROM srt.expedition e
				LEFT JOIN srt.moving m ON m.expeditionFk = e.id
			WHERE e.bufferFk > 0
				AND e.bufferFk != vBufferFk
				AND ISNULL(m.expeditionFk);
	
END$$
DELIMITER ;
