您的位置:首页 > 数据库 > Oracle

oracle 游标实例

2015-08-14 09:41 477 查看
create or replace procedure test

as

 CURSOR cursor_test IS select 5  from dual

            union all  select 6  from dual

            union all  select 7  from dual

            union all  select 8  from dual

            union all  select 9  from dual;

 p_pm1 number;

 p_pm2 number;

begin

 

--打开游标

  open cursor_test;

  LOOP

 

  fetch cursor_test into p_pm1;

  exit when cursor_test%notfound;

 

  select p_pm1 into p_pm2 from dual;

  end loop;

 --关闭游标

 close cursor_test;

 --提交

 commit;

 exception

 when others then

   rollback;

 

end test;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: