mysql 创建存储过程中用到循环,怎么通过select返回结果集 财富值20

2016-11-04 11:57发布

CREATE procedure ceshi(in Str varchar(2048),in SplitChar varchar(50))
begin
declare ind int;
declare unit varchar(128);
declare inext int;
declare len int;
declare i int;
set ind=1;
set i=1;
set len=length(Str);
while ind<=len do
begin
set inext=instr(Str,SplitChar);
if inext=0 then set inext=len+1; end if;
if inext>ind then
begin
set unit=ltrim(rtrim(substring(Str,1,inext-1)));
if unit<>' then
begin
select unit as Value,i as vindex; //这里的select每循环一次,值就不一样,我想让他作为结果集返 //回应该怎么做
set Str=substring(Str,inext+1);
set i=i+1;
select Str,ind,inext,len,unit;
end;
end if;
end;
end if;
end;
set ind=inext+1;
end while;
end;

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1条回答

把值放入数组?

一周热门 更多>