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. PostreSQL崩溃试验全记录

    磨砺技术珠矶,践行数据之道,追求卓越价值 回到上一级页面: PostgreSQL基础知识与基本操作索引页     回到顶级页面:PostgreSQL索引页 [作者 高健@博客园  luckyjackg ...

  2. Kubernetes学习之路(一)之概念和架构解析和证书创建和分发

    1.Kubernetes的重要概念 转自:CloudMan老师公众号<每天5分钟玩转Kubernetes>https://item.jd.com/26225745440.html Clus ...

  3. 洛咕 P2468 [SDOI2010]粟粟的书架

    强行二合一啊... 前面直接二分最小值,二维前缀和.后面用主席树查最小值.注意要写\(nlogn\). // luogu-judger-enable-o2 #include<bits/stdc+ ...

  4. Cocos2DX开发:记录遇到的一些问题和解决方法

    今天看了一下以前学习cocos2dx时记录的一些笔记,主要是在实际中遇到的一些问题,整理了一下,就成为了这篇文章,便于自己以后查找,也为一些新手提供点经验. 这篇文章会一直更新,将自己之后开发中遇到的 ...

  5. Loadrunner 性能指标

    https://wenku.baidu.com/view/bf395a1db7360b4c2e3f64ca.html 希望能记住最好记住吧,这个很重要的. qq,979506750多交流

  6. Java编辑PPT的折线图,与内嵌Excel联动

    /** * 折线图的数据写入方法 * @param slide ppt图表 * @param index 折线图的下标 * @param data 需要填充的数据 * @param titles 内嵌 ...

  7. 'javac' 不是内部或外部命令,也不是可运行的程序 或批处理文件.

    如果你只需要使用javac命令不需要如此复杂的!! 你先把你自己新建的JAVA_HOME.CLASSPATH这两个变量和PATH变量中的JAVA_HOME%\bin;%JAVA_HOME%\jre\b ...

  8. Catlike学习笔记(1.2)-使用Unity画函数图像

    『Catlike系列教程』第二篇来了~今天周六,早上(上午11点)醒来去超市买了一周的零食回来以后就玩了一整天游戏非常有负罪感.现在晚上九点天还亮着感觉像下午7点左右的样子好像还不是很晚...所以就写 ...

  9. 使用Zabbix的SNMP trap监控类型监控设备的一个例子

    本文以监控绿盟设备为例. 1.登录被监控的设备的管理系统,配置snmptrap地址指向zabbix服务器或代理服务器. snmptrap地址也叫陷阱. 2.验证是否能在zabbix服务器或代理服务器上 ...

  10. day13 内置函数

    参考资料: https://www.processon.com/view/link/5b4ee15be4b0edb750de96ac 内置函数: 作⽤域相关: locals()     返回当前作用域 ...