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的更多相关文章

  1. Oracle管道函数(Pipelined Table Function)介绍

    一 概述: 1.管道函数即是能够返回行集合(能够使嵌套表nested table 或数组 varray)的函数,我们能够像查询物理表一样查询它或者将其  赋值给集合变量. 2.管道函数为并行运行,在普 ...

  2. oracle的function和procedure返回值给shell

    本文演示两个关于如何在shell中调用oracle的function和procedure,并将返回值返回给shell. 1.首在package中创建function和procedure,脚本如下: G ...

  3. Oracle table names are case sensitive (normally all uppercase)

    oracle_fdw error desc: postgres=# select * from test; ERROR:  Oracle table "sangli"." ...

  4. ABAP CDS Table Function介绍与示例

    Core data services(以下简称CDS)可以指两样东西,一个是HANA CDS,一个是ABAP CDS. 如我们所知,HANA CDS只支持HANA数据库,ABAP CDS理论上支持多种 ...

  5. sql: Oracle 11g create table, function,trigger, sequence

    --书藉位置Place目录 drop table BookPlaceList; create table BookPlaceList ( BookPlaceID INT PRIMARY KEY, -- ...

  6. Oracle管道函数(Pipelined Table Function)实现的实例

    1. 简单的例子(返回单列的表) 1>创建一个表类型 create or replace type t_table is table of number; 2>创建函数返回上面定义的类型 ...

  7. Oracle 函数function之返回结果集

    工作中常需要经过一段复杂逻辑处理后,得出的一个结果集.并能够将这个结果集作为一个表看待,去进行关联查询 我一般采用建立函数function的方式来处理. --创建包,声明function和typeCR ...

  8. oracle table()函数

    PL/SQL表---table()函数用法/* PL/SQL表---table()函数用法:利用table()函数,我们可以将PL/SQL返回的结果集代替table. oracle内存表在查询和报表的 ...

  9. Oracle SYS_CONTEXT Function

    Version 11.1   Actions As SYS Note: USERENV is an Oracle provided namespace that describes the curre ...

随机推荐

  1. vehicle time series data analysis

    以HADOOP为代表的云计算提供的仅仅是一个算法执行环境,为大数据的并行计算提供了在现有软硬件水平下最好的(近似)方法.并不能解决大数据应用中的全部问题.从详细应用而言,通过物联网方式接入IT圈的数据 ...

  2. 通过setSystemUiVisibility实现状态栏跟Activity之间的位置关系

    曾经说到去除状态栏和标题栏总会用到动态代码的方式实现: getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , Windo ...

  3. 引入jquery.js和jquery-1.10.2.min.js 发生冲突解决办法

    <html><head></head><body><body><div id = "a">a</div ...

  4. EMC存储划分lun过程

    下图是EMC存储系统示意图: 若将lun打散重建,需按以下步骤进行: 1. 在Storage Groups上点右键选择Select Luns,在打开的窗口中,将右边Selected Lun项下的lun ...

  5. 7个好用的在线YouTube视频下载工具

    title: 7个好用的在线YouTube视频下载工具 toc: false date: 2018-10-10 15:11:00 categories: methods tags: youtube C ...

  6. python中is与==的差别

    # is:比较的是两个对象的id值是否相等,# 也就是比较俩对象是否为同一个实例对象,# 是否指向同一个内存地址 # s = "alex"# abc = id(s) # 得到内存地 ...

  7. 体系化认识RPC--转

    原文地址:http://www.infoq.com/cn/articles/get-to-know-rpc?utm_source=infoq&utm_medium=popular_widget ...

  8. php.ini配置文件参数优化

    用于生产环境中的PHP需要对其进行优化,让PHP自身发挥更好的性能,除了写好PHP代码,还要配置好php-fpm以及php.ini调优.本文从内存.OPcache.上传.会话以及安全等方面讲解php. ...

  9. jar文件配置冲突问题transformResourcesWithMergeJavaResForDebug

    先看本人AS报错异常 Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > c ...

  10. Eclipse中使用GIT将已提交到本地的文件上传至远程仓库

    GIT将已提交到本地的文件上传至远程仓库: 1.  右击项目——Team——Push to Upstream,即可将已保存在本地的文件上传推至GIT远程仓库.