-- FUNCTION NAME: agregar_caracter
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `agregar_caracter`(cant INT,patron VARCHAR(50), caracter VARCHAR(1),izq BOOLEAN) RETURNS varchar(100) CHARSET latin1
    DETERMINISTIC
BEGIN
DECLARE dim INT;
SET dim=LENGTH(patron);
WHILE(cant>dim) DO
	IF(izq)THEN

	SET patron=CONCAT(caracter,patron);
	ELSE
	SET patron=CONCAT(patron,caracter);
	END IF;
SET dim=LENGTH(patron);
END WHILE;
RETURN patron;
    END$$
DELIMITER ;

