使用 oracle pipelined 返回一个结果集;
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 返回一个结果集;的更多相关文章
- oracle学习-存储过程返回一个值,和返回一个结果集
一.返回一个值 --创建存储过程 create or replace procedure sp_hu_test(spcode in varchar2,spname out varchar2)is be ...
- oracle pipelined返回值函数 针对数据汇总统计 返回结果集方法
近期需要一个汇总统计,由于数据太多,数据量太大所以在java程序中实现比较困难.若用后台程序统计,数据不能保证实时,同时实现周期比较长.顾使用函数返回结果集的方式,在不增加临时表的情况下实时获取数据. ...
- C#执行参数为游标 返回一个记录集的Oracle存储过程
public DataTable SelectPay_Unit() { string returns = ""; DataTable objDataTable = new Data ...
- exec sp_spaceused如何只返回一个结果集(转载)
问: 我想把每天数据库的大小自动保存到table中但是exec sp_spaceused是返回2个表,执行下面的语句出错,如何解决? drop table db_size go create tabl ...
- 123 c#调用oracle存储过程返回数据集 --通过oracle存储过程返回数据集
c#调用oracle存储过程返回数据集 2008-12-20 10:59:57| 分类: net|字号 订阅 CREATE OR REPLACE PACKAGE pkg_tableTypeIS ...
- c#调用oracle存储过程返回数据集
c#调用oracle存储过程返回数据集 2008-12-20 10:59:57| 分类: net|字号 订阅 CREATE OR REPLACE PACKAGE pkg_tableTypeIS ...
- Entity Framework 6 Recipes 2nd Edition(10-1)译->非Code Frist方式返回一个实体集合
存储过程 存储过程一直存在于任何一种关系型数据库中,如微软的SQL Server.存储过程是包含在数据库中的一些代码,通常为数据执行一些操作,它能为数据密集型计算提高性能,也能执行一些为业务逻辑. 当 ...
- C#中使用Oracle存储过程返回结果集
问题: 在MSSQLServer中定义的存储过程可以直接返回一个数据集,如: create procedure sp_getAllEmployees as SELECT * FROM [NORTHWN ...
- oracle返回多结果集
kavy 原文 oracle返回多结果集 Oracle存储过程: create or replace procedure P_Sel_TopCount2(in_top in number, out_c ...
随机推荐
- EntityFramework使用动态Lambda表达式筛选数据
public static class PredicateBuilder { public static Expression<Func<T, bool>> True<T ...
- cmp(x,y)
cmp(x,y) 函数用于比较2个对象,如果 x < y 返回 -1, 如果 x == y 返回 0, 如果 x > y 返回 1.
- HDU - 5877 Weak Pair (dfs+树状数组)
题目链接:Weak Pair 题意: 给出一颗有根树,如果有一对u,v,如果满足u是v的父节点且vec[u]×vec[v]<=k,则称这对结点是虚弱的,问这棵树中有几对虚弱的结点. 题解: 刚开 ...
- Kafka系列三 java API操作
使用java API操作kafka 1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xs ...
- jsp手动分页
注意: sql语句要写对,jsp显示 List 时的 item的字段名要写对 这里 where uid 要放在前面才能成功执行,否则会报错 , 在写items的时候,如果controller里面已经写 ...
- 通过切换iframe来定位元素(用于Python+selenium自动化测试)
切换 iframe:1.由于登录按钮是在iframe上,所以第一步需要把定位器切换到iframe上2.用switch_to_frame方法切换,此处有id属性,可以直接用id定位切换 iframe 与 ...
- 利用workbench对linux/Ubuntu系统中的mysql数据库进行操作
在上一篇文章中,我分享了在linux中如何安装mysql数据库,但是这只是安装了mysql的服务,并没有图形化管理界面,所以这样子操作起来并没有那么方便,那么现在我们就来实现如何利用在window中安 ...
- L2 Helios OPcodez
天堂2 Helios太阳神版本 的客户端和服务端封包 *********************** Client ***********************00 SendLogOut01 Req ...
- java抽象类与接口区别
java抽象类与接口区别: abstract class和interface是Java语言中对于抽象类定义进行支持的两种机制,正是由于这两种机制的存在,才赋予了Java强大的面向对象能力. abstr ...
- django之基本配置
Python的WEB框架有Django.Tornado.Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定.模板引擎.缓存.Session等诸多功能. ...