dropprocedureifexistsiterateCategory;createprocedureiterateCategory(inrootIdvarchar(20),inrecordtypevarchar(20))begindeclaredoneintdefault0;declarebvarchar(20);declareccu...
drop procedure if exists iterateCategory;
create procedure iterateCategory(in rootId varchar(20),in recordtype varchar(20))
begin
declare done int default 0;
declare b varchar(20);
declare c cursor for select id from cms_category where parent=rootId;
declare continue handler for SQLSTATE '02000' set done = 1;
insert into temp values(rootId);
update cms_category set recordtype=recordtype where id=rootId;
SET @@max_sp_recursion_depth=10;
open c;
fetch c into b;
while(done = 0) do
call iterateCategory(b);
fetch c into b;
end while;
close c;
end;
call iterateCategory('1201011191749550012','1');
调用时报错1318说参数个数不对预期有2个,但只得到一个。传3个参数报错时就是对的说得到3个参数。
我试过把存储过程改成3个参数,但还是类似问题,传3个参数报错说得到一个,传2个参数报错说得到2个。
但当存储过程只有一个参数时就没问题。
我用的mysql5.0+Navicat 8.0
展开