游标参考:
1 create or replace procedure REGION_SENDER_INSERT 2 is 3 begin 4 Execute IMMEDIATE 'TRUNCATE TABLE region_sender_stat '; 5 declare 6 cursor c1 is select REGION_ID from REGION; 7 v_region_id nvarchar2(16); 8 /* v_sender_num Number:=0;*/ 9 begin10 open c1;--打开游标11 fetch c1 into v_region_id;12 while c1 % found loop 13 insert into region_sender_stat(REGION_ID) values (v_region_id);--将区域的id插入到统计表中14 fetch c1 into v_region_id;15 end loop;16 close c1;--关闭游标17 end;18 commit;19 end REGION_SENDER_INSERT;