CREATE PROCEDURE updateTradePerformanceData()
BEGIN
declare stopFlag int;
declare parentOrgId varchar(100);
declare orgaid varchar(100);
DECLARE dataid varchar(100);
declare hasCount int;
-- 申明游标
declare tradePerformanceCuror cursor for
select
fid,fkorgaid
from t_trade_performance;
OPEN tradePerformanceCuror;
REPEAT
FETCH tradePerformanceCuror INTO dataid,orgaid;
BEGIN
select count(1) into hasCount from t_bd_org o where o.fid = orgaid;
if (orgaid is not null and hasCount > 0) then
select o.fkparentid into parentOrgId from t_bd_org o where o.fid = orgaid;
update t_trade_performance set fkorgbid = parentOrgId where fid = dataid;
-- 处理逻辑
end if;
commit;
END;
UNTIL stopFlag = 1
END REPEAT;
CLOSE tradePerformanceCuror;
END;
BEGIN
declare stopFlag int;
declare parentOrgId varchar(100);
declare orgaid varchar(100);
DECLARE dataid varchar(100);
declare hasCount int;
-- 申明游标
declare tradePerformanceCuror cursor for
select
fid,fkorgaid
from t_trade_performance;
-- 申明跳出循环
OPEN tradePerformanceCuror;
REPEAT
FETCH tradePerformanceCuror INTO dataid,orgaid;
BEGIN
select count(1) into hasCount from t_bd_org o where o.fid = orgaid;
if (orgaid is not null and hasCount > 0) then
select o.fkparentid into parentOrgId from t_bd_org o where o.fid = orgaid;
update t_trade_performance set fkorgbid = parentOrgId where fid = dataid;
-- 处理逻辑
end if;
commit;
END;
UNTIL stopFlag = 1
END REPEAT;
CLOSE tradePerformanceCuror;
END;