I'm trying to get a random string in phpmyadmin using a function. I have the followin code:
CREATE FUNCTION randomPassword()
RETURNS varchar(128)
BEGIN
SET @chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
SET @charLen = length(@chars);
SET @randomPassword = '';
WHILE length(@randomPassword) < 12
SET @randomPassword = concat(@randomPassword, substring(@chars,CEILING(RAND() * @charLen),1));
END WHILE;
RETURN @randomPassword ;
END;
Now i get the error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
does anyone know ho it has to be?
Aucun commentaire:
Enregistrer un commentaire