Ref_cursor

Ref_cursor属于动态cursor(直到运行时才知道这条查询)。

返回一个Table.

--说明:从ERP数据库查询出所有的店铺
    --作者:杨斌
    --日期:2012-08-09
    procedure getAllShopsFromERP(
             all_shops_out out sys_refcursor,    --返回店铺结果集
             out_error_row out number,           --错误行
             out_error_msg out varchar2          --错误信息
             )
    is
   
      str_sql varchar2(4000);--定义查询SQL语句变量
    begin
   
   
      out_error_row :=0;--错误行
      out_error_msg :='';--错误信息
      --用链查询店铺信息表
      str_sql := 'select * from T_Base_ShopPublic@yb' ;--连接ERP数据库的链
      out_error_row :=1000;--错误行
      dbms_output.put_line(str_sql);
      open all_shops_out for str_sql;
       
    exception
      when others then
        out_error_msg := '数据库错误:' || sqlerrm;
       
    end getAllShopsFromERP;

测试:

原文地址:https://www.cnblogs.com/YangBinChina/p/2653917.html