存储过程中双循环迭代数据

create or replace procedure pro_zszg_report6 is

--让游标变量c_emps指向一个动态select查询的结果集

cursor c_report is select * from hbrmw6.rms_zszg_report ;

--5G基站数

cursor c_report6 is select re.city_id,re.county_id,ce.related_wg,wg.zh_label,count(*) nums from hbrmw6.RMS_G_NODEB re,hbrmw6.rms_equiproom rm,hbrmw6.RMS_NR_CELL ce,hbrmw6.rms_market_wangge wg where re.related_room=rm.int_id and ce.related_room=rm.int_id and ce.related_wg=wg.resno and re.stateflag='0' and re.status='现网' group by re.city_id,re.county_id,ce.related_wg,wg.zh_label;

begin

--循环开始

for e in c_report loop

for e6 in c_report6 loop

if (e.city_id =e6.city_id) and (e.county_id=e6.county_id) and (e.wangge=e6.zh_label) then

update hbrmw6.rms_zszg_report rt set rt.G5g_Site_Num=e6.nums where rt.city_id=e6.city_id and rt.county_id=e6.county_id and rt.wangge=e6.zh_label;

commit;

end if;

--循环2结束

end loop;

--循环1结束

end loop;

end pro_zszg_report6;

相关推荐
Tapdata2 小时前
《实时分析市场报告 2025》上线 | 从批处理到实时洞察,2025 年全球实时分析市场全景解读
数据库
海梨花2 小时前
【从零开始学习Redis】项目实战-黑马点评D2
java·数据库·redis·后端·缓存
代码的余温3 小时前
SQL性能优化全攻略
数据库·mysql·性能优化
手把手入门5 小时前
★CentOS:MySQL数据备份
数据库·mysql·adb
SelectDB6 小时前
5000+ 中大型企业首选的 Doris,在稳定性的提升上究竟花了多大的功夫?
大数据·数据库·apache
路多辛6 小时前
Golang database/sql 包深度解析(二):连接池实现原理
数据库·sql·golang
SimonKing6 小时前
Mybatis批量插入,形式不同性能也不同
数据库·后端·程序员
杰克尼7 小时前
MYSQL-175. 组合两个表
数据库·mysql
DemonAvenger7 小时前
MySQL索引原理深度解析与优化策略实战
数据库·mysql·性能优化
189228048618 小时前
NY270NY273美光固态闪存NY277NY287
服务器·网络·数据库·科技·性能优化