oracle 儲存過程(其中使用了遊標)例子
阿新 • • 發佈:2019-02-04
create or replace procedure PRC_analysis_alert is ---獲得“預警研判分析-預警資訊統計”結果 的遊標 cursor CRS_AlERT is select xzqh, zzjgdm , yjlx ,substr(TJRQ,1,6) tjyf ,clzt ,sum(yjsl) yjsl from t_pvbdp_statistics_alert group by xzqh, zzjgdm , yjlx ,substr(TJRQ,1,6) ,clzt ; begin ----預警研判分析 - 預警資訊統計 execute immediate 'truncate table t_pvbdp_analysis_alert' ; for alert_msg in CRS_AlERT loop begin insert into t_pvbdp_analysis_alert (id, tjyf,xzqh, zzjgdm, yjlx, clzt, yjsl) values (sys_guid() , alert_msg.tjyf, alert_msg.xzqh, alert_msg.zzjgdm, alert_msg.yjlx, alert_msg.clzt, alert_msg.yjsl); end; end loop; end PRC_analysis_alert;