以下是我的代码,编译会出错。如果把call splitString(strIds,",");放在游标声明后面,就可以编译通过。不知道为什么
PHP code
CREATE DEFINER=`root`@`%` PROCEDURE `InitUserMail`(strIds varchar(500))
BEGIN
declare uid int;
declare done int;
call splitString(strIds,",");
DECLARE rs_cursor CURSOR FOR select status from tmp_split;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
set done = 0;
open rs_cursor;
cursor_loop:loop
FETCH rs_cursor into uid;
if done=1 then
leave cursor_loop;
end if;
if uid then
call CreateUserMailOption(uid);
call CreateUserMailBox(uid);
end if;
end loop cursor_loop;
close rs_cursor;
END
mysql 存储过程中 declare声明的操作都要放在最前面
declare必须放在其他的语句前面,这是mysql语法决定的。