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

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;

相关推荐
余衫马32 分钟前
CentOS7 离线安装 Postgresql 指南
数据库·postgresql
E___V___E1 小时前
MySQL数据库入门到大蛇尚硅谷宋红康老师笔记 高级篇 part 2
数据库·笔记·mysql
m0_748254881 小时前
mysql之如何获知版本
数据库·mysql
mikey棒棒棒2 小时前
Redis——优惠券秒杀问题(分布式id、一人多单超卖、乐悲锁、CAS、分布式锁、Redisson)
数据库·redis·lua·redisson·watchdog·cas·并发锁
水手胡巴3 小时前
oracle apex post接口
数据库·oracle
史迪仔01125 小时前
【SQL】SQL多表查询
数据库·sql
Quz6 小时前
MySQL:修改数据库默认存储目录与数据迁移
数据库·mysql
Familyism6 小时前
Redis
数据库·redis·缓存
隔壁老登6 小时前
查询hive指定数据库下所有表的建表语句并生成数据字典
数据库·hive·hadoop
sekaii6 小时前
ReDistribution plan细节
linux·服务器·数据库