首页 > 数据库技术 > 详细

Oracle 存储过程 游标

时间:2015-11-07 19:17:41      阅读:202      评论:0      收藏:0      [点我收藏+]

1 test 

2

----包
create or replace package test_pkg1 is
  procedure test_p(v_id   in sys_user.id%type,
                   v_name in sys_user.name%type,
                   msg    out varchar);
end test_pkg1;
-- 包体
create or replace package body test_pkg1 is
  procedure test_p(v_id   in sys_user.id%type,
                   v_name in sys_user.name%type,
                   msg    out varchar) is
    v_t_id   number;
    v_t_name sys_user.name%type;
    ---游标
    cursor cor1 is
      select p.id, p.name from sys_user p;
  begin
    open cor1;
    loop
      fetch cor1
        into v_t_id, v_t_name;
      exit when cor1%notfound;
      dbms_output.put_line(v_t_id || ‘  - ‘ || v_t_name);
      msg := msg || v_t_name;
    end loop;
    close cor1;
  end test_p;
end test_pkg1;

declare v_msg varchar2(500);
begin
test_pkg1.test_p(23, ‘test‘, v_msg); dbms_output.put_line(v_msg);
end;
-----

3


Oracle 存储过程 游标

原文:http://my.oschina.net/xwl1990/blog/527458

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!