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. tornado-About Web

    1.轻量级的web开发框架,没有像django那样的命令行工具,只用于写一些小的脚本 (1)安装tornado包 pip intall tornado # conda install tornado( ...

  2. 洛咕 P4199 万径人踪灭

    给了两条限制,但是第二条想想是没用的,直接manacher就可以减掉多余的部分了,所以要求满足第一条的方案 也不难,可以想到枚举每个中心点,计算两边有多少对距离中心相等的位置值也相等,假设有\(t\) ...

  3. 解决 java循环中使用 Map时 在put值时value值被覆盖的问题

    其实很简单,只需要把容器换成list 然后在循环中,每次循环末尾map = new HashMap() 或者直接在循环中一开始就实例化hashmap(Map map = new HashMap();) ...

  4. python之GIL(Global Interpreter Lock)

    一 介绍 ''' 定义: In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple nati ...

  5. PowerDesigner中翻转生成PDM图时把Name属性变成注释(转)

    在pd里面运行下面这段代码'******************************************************************************'* File: ...

  6. 【Unity Shader】(七) ------ 复杂的光照(下)

    笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题.              [Unity Sha ...

  7. oracle的多表合并查询-工作心得

    本随笔文章,由个人博客(鸟不拉屎)转移至博客园 发布时间: 2018 年 11 月 29 日 原地址:https://niaobulashi.com/archives/oracle-select-al ...

  8. HTML6的10个高级新特性

    网络技术正趋向于发展为一个巨大的移动APP市场,在Web开发的革命浪潮中起着指示性作用,自HTML引入以来,应用程序变得So easy,web开发中运用先进技术也很容易处理各种复杂Bug. 作为专业的 ...

  9. 来源自rnnoise,但非rnn

    很快又一年过去了. 自学音频算法也近一年了. 不记得有多少个日日夜夜, 半夜醒来,就为验证算法思路. 一次又一次地改进和突破. 傻逼样的坚持,必然得到牛逼样的结果. 这一年,主要扎音频算法上. 经常有 ...

  10. 010 --MySQL查询优化器的局限性

    MySQL的万能"嵌套循环"并不是对每种查询都是最优的.不过还好,mysql查询优化器只对少部分查询不适用,而且我们往往可以通过改写查询让mysql高效的完成工作.在这我们先来看看 ...