1.使用

 create or replace package refcursor_pkg is

   -- Author  : mr.yang
-- Created : 5/14/2017 5:13:42 PM
-- Purpose :
type refcur_t is ref cursor return sys_product%rowtype;
type refcur_t1 is ref cursor /*return sys_product%rowtype*/
;
type refcur_t2 is ref cursor return base_member%rowtype; type outrec_typ is record(
v_pid integer,
v_pcode varchar(4000),
v_pname varchar(4000)); type outrecset is table of outrec_typ;
function f_trans(p refcur_t) return outrecset
pipelined;
function f_trans1(p refcur_t1) return outrecset
pipelined;
function f_trans1(sp refcur_t1, bm refcur_t2) return outrecset
pipelined; end refcursor_pkg;

2.body

 create or replace package body refcursor_pkg is
function f_trans(p refcur_t) return outrecset
pipelined as
out_rec outrec_typ;
in_rec p%rowtype; begin loop
fetch p
into in_rec;
exit when p%notfound;
out_rec.v_pid := in_rec.productid;
out_rec.v_pcode := in_rec.productcode;
out_rec.v_pname := in_rec.productname; pipe row(out_rec);
end loop;
close p;
return;
Exception
when others then
dbms_output.put_line(sqlcode || sqlerrm);
end f_trans; function f_trans1(p refcur_t1) return outrecset
pipelined as
out_rec outrec_typ;
in_rec sys_product%rowtype;
begin
loop
fetch p
into in_rec;
exit when p%notfound;
out_rec.v_pid := in_rec.productid;
out_rec.v_pcode := in_rec.productcode;
out_rec.v_pname := in_rec.productname; pipe row(out_rec);
end loop;
close p;
return;
Exception
when others then
dbms_output.put_line(sqlcode || sqlerrm); end f_trans1;
---------------------------------------------------------
function f_trans1(sp refcur_t1, bm refcur_t2) return outrecset
pipelined as out_rec outrec_typ;
in_rec sys_product%rowtype;
in_rec_bm bm%rowtype;
begin loop
fetch sp
into in_rec;
exit when sp%notfound;
/* out_rec.v_pid := in_rec.productid;
out_rec.v_pcode := in_rec.productcode;
out_rec.v_pname := in_rec.productname;
pipe row(out_rec);
out_rec.v_pid := in_rec_bm.id;
out_rec.v_pcode := in_rec_bm.cnfullname;
out_rec.v_pname := in_rec_bm.pinyin;
pipe row(out_rec);*/ end loop;
close sp; loop
fetch bm
into in_rec_bm;
exit when bm%notfound;
out_rec.v_pid := in_rec_bm.id;
out_rec.v_pcode := in_rec_bm.cnfullname;
out_rec.v_pname := in_rec_bm.pinyin;
pipe row(out_rec); out_rec.v_pid := in_rec.productid;
out_rec.v_pcode := in_rec.productcode;
out_rec.v_pname := in_rec.productname;
pipe row(out_rec);
end loop;
close bm; return;
Exception
when others then
dbms_output.put_line(sqlcode || sqlerrm); end f_trans1; end refcursor_pkg;

3.结果:

使用 oracle pipelined 返回一个结果集;的更多相关文章

  1. oracle学习-存储过程返回一个值,和返回一个结果集

    一.返回一个值 --创建存储过程 create or replace procedure sp_hu_test(spcode in varchar2,spname out varchar2)is be ...

  2. oracle pipelined返回值函数 针对数据汇总统计 返回结果集方法

    近期需要一个汇总统计,由于数据太多,数据量太大所以在java程序中实现比较困难.若用后台程序统计,数据不能保证实时,同时实现周期比较长.顾使用函数返回结果集的方式,在不增加临时表的情况下实时获取数据. ...

  3. C#执行参数为游标 返回一个记录集的Oracle存储过程

    public DataTable SelectPay_Unit() { string returns = ""; DataTable objDataTable = new Data ...

  4. exec sp_spaceused如何只返回一个结果集(转载)

    问: 我想把每天数据库的大小自动保存到table中但是exec sp_spaceused是返回2个表,执行下面的语句出错,如何解决? drop table db_size go create tabl ...

  5. 123 c#调用oracle存储过程返回数据集 --通过oracle存储过程返回数据集

    c#调用oracle存储过程返回数据集 2008-12-20 10:59:57|  分类: net|字号 订阅   CREATE OR REPLACE PACKAGE pkg_tableTypeIS  ...

  6. c#调用oracle存储过程返回数据集

    c#调用oracle存储过程返回数据集 2008-12-20 10:59:57|  分类: net|字号 订阅   CREATE OR REPLACE PACKAGE pkg_tableTypeIS  ...

  7. Entity Framework 6 Recipes 2nd Edition(10-1)译->非Code Frist方式返回一个实体集合

    存储过程 存储过程一直存在于任何一种关系型数据库中,如微软的SQL Server.存储过程是包含在数据库中的一些代码,通常为数据执行一些操作,它能为数据密集型计算提高性能,也能执行一些为业务逻辑. 当 ...

  8. C#中使用Oracle存储过程返回结果集

    问题: 在MSSQLServer中定义的存储过程可以直接返回一个数据集,如: create procedure sp_getAllEmployees as SELECT * FROM [NORTHWN ...

  9. oracle返回多结果集

    kavy 原文 oracle返回多结果集 Oracle存储过程: create or replace procedure P_Sel_TopCount2(in_top in number, out_c ...

随机推荐

  1. 3235: [Ahoi2013]好方的蛇

    3235: [Ahoi2013]好方的蛇 链接 分析: 可以求出以每个点为顶点的满足条件的矩形有多少个,单调栈求.设为sum. 然后对这个数组进行二维前缀和,可以求出每个矩阵内,以右下角.左下角为端点 ...

  2. android 动态控制状态栏显示和隐藏

    方法一:(经试验无效,但网上广为流传,也许是我使用方法不当,有待进一步验证……) android想要应用运行时全屏有一种方法是在activity的onCreat方法中加入如下代码: getWindow ...

  3. python爬虫之Scrapy框架(CrawlSpider)

    提问:如果想要通过爬虫程序去爬取”糗百“全站数据新闻数据的话,有几种实现方法? 方法一:基于Scrapy框架中的Spider的递归爬去进行实现的(Request模块回调) 方法二:基于CrawlSpi ...

  4. jQuery中attr()函数 VS prop()函数

    http://www.365mini.com/page/jquery-attr-vs-prop.htm 在jQuery中,attr()函数和prop()函数都用于设置或获取指定的属性,它们的参数和用法 ...

  5. 使用 Python+Selenium 破解滑块验证码

    ​​开发工具 Python版本:3.6.4 相关模块: pillow模块: selenium模块: numpy模块: 以及一些Python自带的模块. 其他: chromedriver 环境搭建 安装 ...

  6. sqlite3 数据库命令操作

    SQLite 数据库,是一个非常轻量级自包含(lightweight and self-contained)的DBMS,它可移植性好,很容易使用,很小,高效而且可靠. SQLite嵌入到使用它的应用程 ...

  7. Winfrom Panel Scroll End 的实现

    场景:在一个panel里面有非常多的自定义绘制的控件,在拖拉滚动条的时候,控件的画面上有残影 不知道大家遇到过这种情况没,一直做web的winform经验太少,有更好的解决办法请贡献 首先放出我的解决 ...

  8. vs2019编译redis

    版本信息 使用Redis源码版本,解压工程右键生成hiredis项目正常,编译Win32_Interop项目报下图错误(error C2039:system_error:不是std成员;error C ...

  9. Unity2018 Shader Graph 实验室

    Unity2018 Shader Graph 实验室 Shader Shader Graph Unity  Tips: -- 在shader forge和amplyfy Shader节点图形化shad ...

  10. Linux下出现permission denied的解决办法

    Linux下经常出现permission denied,原因是由于权限不足,有很多文章通过chmod命令更改权限为777,但是很不方便也不适合新手,简单粗暴的方法如下: 命令行中输入 sudo pas ...