select f_cliente_aleatorio() LIMIT 0, 10000 Error Code: 1264. Out of range value for column 'f_cliente_aleatorio()' at row 1 0.000 sec
Minha função f_numero_aleatorio:
CREATE DEFINER=`root`@`localhost` FUNCTION `f_numero_aleatorio`(min int, max int) RETURNS int(11)
BEGIN
declare vRetorno int;
select floor((rand() * (max - min + 1)) + min) into vRetorno;
RETURN vRetorno;
END
Minha função f_cliente_aleatorio:
CREATE DEFINER=`root`@`localhost` FUNCTION `f_cliente_aleatorio`() RETURNS int(11)
BEGIN
declare vRetorno varchar(11);
declare num_max_tabela int;
declare num_aleatorio int;
select count(*) into num_max_tabela from tabela_de_clientes;
set num_aleatorio = f_numero_aleatorio(1, num_max_tabela);
set num_aleatorio = num_aleatorio - 1;
select CPF into vRetorno from tabela_de_clientes limit num_aleatorio, 1;
RETURN vRetorno;
END