oracle-游标循环


--For 循环游标
--(1)定义游标
--(2)定义游标变量
--(3)使用for循环来使用这个游标
declare
--类型定义
cursor c_job
is
select distinct a.fakeid,a.nick_name,b.openid
from ajydev_weixin_temp1 a,ajydev_weixin_temp2 b
where a.date_time=b.date_time and a.msg_content=b.msg_content;
--定义一个游标变量v_cinfo c_emp%ROWTYPE ,该类型为游标c_emp中的一行数据类型
c_row c_job%rowtype;
begin
for c_row in c_job loop
-------------------------------------------------------------
delete from ajydev_weixin_zh_info a where a.openid=c_row.openid;
insert into ajydev_weixin_zh_info(openid, fakeid, nick_name)
values(c_row.openid, c_row.fakeid, c_row.nick_name);
-------------------------------------------------------------
end loop;
end;

 

posted @ 2013-10-21 14:20  旦旦哥  阅读(1426)  评论(0编辑  收藏  举报