网站域名备案和icp备案一样么,电商运营发展前景怎么样,网站建设 html,天水网站seo关于mysql 存储过程内实现循环#xff0c;在用repeat 时发现#xff0c; 很容易因为done的值循环终止。为此研究了下 do while来实现 循环。
过程和repeat 大差不差#xff0c;值得注意的是 多了一个循环次数#xff0c;通过该变量去定义我们要循环的次数。
做了一个简易…关于mysql 存储过程内实现循环在用repeat 时发现 很容易因为done的值循环终止。为此研究了下 do while来实现 循环。
过程和repeat 大差不差值得注意的是 多了一个循环次数通过该变量去定义我们要循环的次数。
做了一个简易的demo如下有需要的可自行copy。
CREATE DEFINERroot% PROCEDURE overview_financial_data_yl(dateTime varchar(100),regionId varchar(100))
BEGIN-- 定义变量 成本中心编码
DECLARE vcenter_code varchar(64);
DECLARE v_maxmonth varchar(64);DECLARE v_changeNum bigint(12);
DECLARE in_Num bigint(12);DECLARE dayInfo CURSOR FOR
select center_code
from big_data.sys_dept
where status0 and del_flag0 and dept_level3 and dept_attr in(1,4)
and if(regionId0,11,FIND_IN_SET(regionId,ancestors)); -- 循环次数
select count(1) into in_Num
from big_data.sys_dept
where status0 and del_flag0 and dept_level3 and dept_attr in(1,4)
and if(regionId0,11,FIND_IN_SET(regionId,ancestors));set zcws0;
set zylrs0;
set shzylr0;set wbzylr0;
set shcwsy0;
set shcwsy0;
set wbsycw0;
set shcwzs0;
set v_changeNum0;OPEN dayInfo;SET j1;WHILE jin_Num DOFETCH dayInfo INTO vcenter_code;-- 数据处理逻辑SET jj1;END WHILE;CLOSE dayInfo;select zcws;select zylrs;select shzylr;select shcwsy;select wbzylr;select wbsycw;select shcwzs;END好了到这里就结束了。