论坛首页 编程语言技术论坛

oracle 包和存储过程 实例

浏览 2879 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-06-28  

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;
 

 

 

 

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics