当前位置:Gxlcms > 数据库问题 > Oracle 存储过程 游标

Oracle 存储过程 游标

时间:2021-07-01 10:21:17 帮助过:3人阅读

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 存储过程 游标

标签:

人气教程排行