Oracle Table Function
Oracle Table Function在Oracle9i时引入。完美的兼容了view和存储过程的长处:
应用举例:
1.Table()函数:
set feedback off create or replace type type_int_date_varchar2 as object (i integer, d date, v varchar2(99))
/ create or replace type table_int_date_varchar2 as table of
type_int_date_varchar2
/ create or replace function f_int_date_varchar2 return table_int_date_varchar2 as
a_type_int_date_varchar2 table_int_date_varchar2 := table_int_date_varchar2();
begin a_type_int_date_varchar2.extend;
a_type_int_date_varchar2(a_type_int_date_varchar2.count) :=
type_int_date_varchar2(1,to_date('08.01.1947','dd.mm.yyyy'), 'David Bowie'); a_type_int_date_varchar2.extend;
a_type_int_date_varchar2(a_type_int_date_varchar2.count) :=
type_int_date_varchar2(2,to_date('27.01.1756','dd.mm.yyyy'), 'Mozart'); return a_type_int_date_varchar2;
end;
/ select * from table (cast (f_int_date_varchar2() as table_int_date_varchar2)); drop function f_int_date_varchar2;
drop type table_int_date_varchar2;
drop type type_int_date_varchar2;
2.A Function that returns a table of dates in a Range
create or replace type date_obj as object (dt date)
/ create or replace type date_table as table of date_obj
/ create or replace function date_range(from_dt in date, to_dt in date)
return date_table as
a_date_table date_table := date_table();
cur_dt date:=from_dt;
begin
while cur_dt <= to_dt loop
a_date_table.extend;
a_date_table(a_date_table.count) := date_obj(cur_dt);
cur_dt := cur_dt + 1;
end loop;
return a_date_table;
end date_range;
/
select * from table (
cast ( date_range(
to_date('01.01.2002','dd.mm.yyyy'),
to_date('31.01.2002','dd.mm.yyyy')
)
as date_table
));
Oracle Table Function的更多相关文章
- Oracle管道函数(Pipelined Table Function)介绍
一 概述: 1.管道函数即是能够返回行集合(能够使嵌套表nested table 或数组 varray)的函数,我们能够像查询物理表一样查询它或者将其 赋值给集合变量. 2.管道函数为并行运行,在普 ...
- oracle的function和procedure返回值给shell
本文演示两个关于如何在shell中调用oracle的function和procedure,并将返回值返回给shell. 1.首在package中创建function和procedure,脚本如下: G ...
- Oracle table names are case sensitive (normally all uppercase)
oracle_fdw error desc: postgres=# select * from test; ERROR: Oracle table "sangli"." ...
- ABAP CDS Table Function介绍与示例
Core data services(以下简称CDS)可以指两样东西,一个是HANA CDS,一个是ABAP CDS. 如我们所知,HANA CDS只支持HANA数据库,ABAP CDS理论上支持多种 ...
- sql: Oracle 11g create table, function,trigger, sequence
--书藉位置Place目录 drop table BookPlaceList; create table BookPlaceList ( BookPlaceID INT PRIMARY KEY, -- ...
- Oracle管道函数(Pipelined Table Function)实现的实例
1. 简单的例子(返回单列的表) 1>创建一个表类型 create or replace type t_table is table of number; 2>创建函数返回上面定义的类型 ...
- Oracle 函数function之返回结果集
工作中常需要经过一段复杂逻辑处理后,得出的一个结果集.并能够将这个结果集作为一个表看待,去进行关联查询 我一般采用建立函数function的方式来处理. --创建包,声明function和typeCR ...
- oracle table()函数
PL/SQL表---table()函数用法/* PL/SQL表---table()函数用法:利用table()函数,我们可以将PL/SQL返回的结果集代替table. oracle内存表在查询和报表的 ...
- Oracle SYS_CONTEXT Function
Version 11.1 Actions As SYS Note: USERENV is an Oracle provided namespace that describes the curre ...
随机推荐
- XTU1201:模和除
题目描写叙述 两个整数x和y,满足1<=x<=a,1<=y<=b 且x%y等于x/y的x和y的对数有多少? x%y是x除以y的余数, x/y是x除以y的商,即整数除. 输入 不 ...
- unity3d面试题摘选(全)
======================================= 数据结构和算法非常重要.图形学也非常重要! 大的游戏公司非常看重个人基础.综合能力.也有的看重你实际工作能力,看你的De ...
- DNS查询报文实例
2.2 DNS查询报文实例 以www.baidu.com为例,用Wireshark俘获分组,结合2.1的理论内容,很容易看明白的,DNS请求报文如下: 图7 DNS请求报文示例 2.3 DNS回答报文 ...
- 信息安全-加密:MD5
ylbtech-信息安全-加密:MD5 MD5消息摘要算法(英语:MD5 Message-Digest Algorithm),一种被广泛使用的密码散列函数,可以产生出一个128位(16字节)的散列值( ...
- 杂项-电信:TL9000
ylbtech-杂项-电信:TL9000 TL9000是电信业质量体系要求(书1)与质量体系法则(书2)的指南, 它包括ISO9001的所有要求,以及硬件.软件, 服务方面行业的特别要求. 这些新增要 ...
- 19. Remove Nth Node From End of List[M]删除链表的倒数第N个节点
题目 Given a linked list, remove the n-th node from the end of list and return its head. *Example: Giv ...
- .NET平台开源JSON序列化
转载: http://blog.csdn.net/ddgweb/article/details/39643747 一个简单示例: String str = "{’name’:’cyf’,’i ...
- C# MVC登录判断状态
public class AuthenAdminAttribute:FilterAttribute,IAuthorizationFilter { public void OnAuthenticatio ...
- Photoshop保存文件时的选项
以 JPEG 格式存储 您可以使用"存储为"命令以 JPEG (*.jpg) 格式存储 CMYK.RGB 和灰度图像.JPEG 通过有选择地扔掉数据来压缩文件大小.也可以使用&qu ...
- java根据出生日期计算年龄
/** * @author jerry.chen * @param brithday * @return * @throws ParseException * 根据生日获取年龄; */ public ...