Error 1313: RETURN is only allowed in a FUNCTION SQL Statement

1、错误描述

14:07:26	Apply changes to rand_string	Error 1313: RETURN is only allowed in a FUNCTION SQL Statement:  CREATE PROCEDURE `rand_string` (n int)  BEGIN   DECLARE chars varchar(100) DEFAULT 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';                 DECLARE return_str varchar(255) DEFAULT '';                 DECLARE i INT DEFAULT 0;                 WHILE i < n DO                                 SET return_str = concat(return_str,substring(chars , FLOOR(1 + RAND()*52 ),1));                           SET i = i +1;                 END WHILE;                 RETURN return_str; END   

2、错误原因

    由上述可知,RETURN仅仅只能在函数SQL语句里用


3、解决办法

    修改存储过程,去掉RETURN值

原文地址:https://www.cnblogs.com/hzcya1995/p/13314539.html