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

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;

相关推荐
我科绝伦(Huanhuan Zhou)15 分钟前
探索技术世界:我的GitHub数据库工具宝库
数据库·github
猫的玖月1 小时前
(一)MY SQL概述
数据库·sql
脑子进水养啥鱼?1 小时前
PostgreSQL .history 文件
数据库·postgresql
倔强的石头_2 小时前
5 个真实案例带你避坑:DolphinDB 实时写入、流订阅与高可用调优
数据库
虹科网络安全2 小时前
艾体宝新闻|Redis 月度更新速览:2026 年 3 月
数据库·redis·缓存
Nturmoils2 小时前
DolphinDB 实时时序数据处理踩坑实录:5 类生产故障排查与优化
数据库
csdn2015_2 小时前
postgresql 拼接字段
数据库
\xin2 小时前
pikachu自编SQL(POST)
java·数据库·sql
2301_815901972 小时前
SQL如何将多行记录聚合成逗号分隔字符串_GROUP_CONCAT技巧
jvm·数据库·python
秋93 小时前
Kingbase下载、安装和使用详解
数据库