当前位置:首页 > 开发 > 数据库 > 正文

oracle 包和存储过程 实例

发表于: 2012-06-28   作者:blackproof   来源:转载   浏览:
摘要: oracle package 小例子,以及一个存储过程的应用     create or replace package query_project_pck as type pro_ref_cursor_type is ref cursor; type pro_table is table of varchar(100); type pro_record

oracle package 小例子,以及一个存储过程的应用

 

 

create or replace package query_project_pck
as 
type pro_ref_cursor_type is ref cursor;
type pro_table is table of varchar(100);
type pro_record is record(name varchar(100),id varchar(100));
procedure pro_procedure(name varchar,id varchar);
end query_project_pck; -- define package

create or replace procedure query_pro(pro_result out query_project_pck.pro_ref_cursor_type) is
begin
  open pro_result for
    select pro.xmid, pro.xmmc,pro.updatetime from T_LPROMIS_XMGL_GBBXMXX pro return pro_record_type;
end; --create procedure using ref cursor

-- test procedure using ref cursor
declare
  pro_cursor query_project_pck.pro_ref_cursor_type;
  id         T_LPROMIS_XMGL_GBBXMXX.Xmid%type;
  name       T_LPROMIS_XMGL_GBBXMXX.Xmmc%type;
  pro_record pro_record_type;
begin
  query_pro(pro_cursor);
  loop
    fetch pro_cursor
      into pro_record;
    exit when pro_cursor%notfound;
    dbms_output.put_line(pro_record.id || ' ' || pro_record.name || '  '|| pro_record.updatetime );
  end loop;
  close pro_cursor;
  --for pro_record in pro_cursor loop
  --   dbms_output.put_line(pro_record.xmid,pro_record.xmmc);
  --end loop;
end;
 

 

 

 

oracle 包和存储过程 实例

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号