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. STM32通用定时器配置

    一.STM32通用定时器原理 STM32 系列的CPU,有多达8个定时器,其中TIM1和TIM8是能够产生三对PWM互补输出的高级定时器,常用于三相电机的驱动,它们的时钟由APB2的输出产生.其它6个 ...

  2. CF248E Piglet's Birthday

    题面 题意翻译 给定$n$个货架,初始时每个上面有$a[i]$个蜜罐. 有$q$次操作,每次操作形如$u,v,k$,表示从货架$u$上任意选择$k$个蜜罐试吃(吃过的也还能吃),吃完后把这$k$个蜜罐 ...

  3. sprinboot之mongodb

    一.MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当 ...

  4. idea中xml打开方式变成file,改回来

    原文:https://blog.csdn.net/u012903926/article/details/80682885 创建了一个test文件,用的是普通text打开方式,然后你修改文件为test. ...

  5. 服务器路由配置--Route

    第1章 命令配置 虚拟服务器 网卡配置信息 虚拟网卡名称 虚拟网卡模式 服务器01 eth1 10.0.0.10/24 nat模式 服务器02 eth2 10.0.0.11/24 nat模式 eth3 ...

  6. 【总结】详细说说Html.ActionLink的用法

    Html.ActionLink概述 在MVC的Rasor视图引擎中,微软采用一种全新的方式来表示从前的超链接方式,它代替了从前的繁杂的超链接标签,让代码看起来更加简洁,通过浏览器依然会解析成传统的a标 ...

  7. ABORT: Can't find command 'my_print_defaults'.

    解决办法是输入如下命令: export PATH=/usr/local/mysql/bin:$PATH 将/usr/local/mysql/bin加到$PATH环境变量里

  8. 零基础学python之构建web应用(入门级)

    构建一个web应用 前面的学习回顾: IDLE是Python内置的IDE,用来试验和执行Python代码,可以是单语句代码段,也可以是文本编辑器中的多语句程序. 四个内置数据结构:列表.字典.集合和元 ...

  9. mysql读写分离配置(整理)

    mysql读写分离配置 环境:centos7.2 mysql5.7 场景描述: 数据库Master主服务器:192.168.206.100 数据库Slave从服务器:192.168.206.200 M ...

  10. Notes of Daily Scrum Meeting(11.10)

    Notes of Daily Scrum Meeting(11.10) 今天是周一,虽然仍然在假期里,但是我们仍然要继续我们团队的开发工作了,分工大家已然都很明确,所以接下来 就是认真投入,把自己负责 ...