我想传入一个 int 值并返回一个小于这个 int 的短密码列表。我在修改 MySQL 游标示例时遇到了麻烦:http: //dev.mysql.com/doc/refman/5.0/en/cursors.html。我想用短密码打印出行,但任何时候结果有不止一行 PhpMyAdmin 只会无限期地显示“处理请求”。我究竟做错了什么?它破坏了我周六的生产力!
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `ShortPasswd`(IN `passwordLength` TINYINT)
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE a INT;
DECLARE b VARCHAR(255);
DECLARE cur1 CURSOR FOR SELECT UID, Password
FROM authentication WHERE CHARACTER_length(Password) < passwordLength;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a, b;
IF done THEN
LEAVE read_loop;
END IF;
SELECT b;
END LOOP;
CLOSE cur1;
END
$$
DELIMITER ;