DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `pbx`.`queue_isValid`(vQueue VARCHAR(255))
BEGIN
/**
 * Check if an queue has the correct format and
 * throws an exception if it hasn't.
 *
 * @param vQueue The queue number
 */
	DECLARE vIsValid BOOL;

	SET vIsValid = vQueue IS NULL
		OR vQueue REGEXP '^[1-9][0-9]00$';

	IF NOT vIsValid THEN
		SIGNAL SQLSTATE '45000'
			SET MESSAGE_TEXT = 'Queue format is invalid';
	END IF;
END$$
DELIMITER ;
