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. 读配置文件能够保持顺序的 Java Properties 类

    序 前几天,公司项目中有一个需求是读取配置文件的.并且最好可以保证载入到内存中的顺序可以和配置文件里的顺序一致,可是.假设使用 jdk 中提供的 Properties 类的话,读取配置文件后.载入到内 ...

  2. bzoj3713: [PA2014]Iloczyn(乱搞)

    3713: [PA2014]Iloczyn 题目:传送门 题解: 随手一发水题x2 直接离线啊,斐波那契到了第五十个就炒鸡大了 代码: #include<cstdio> #include& ...

  3. 英语发音规则---V字母

    英语发音规则---V字母 一.总结 一句话总结: 1.V发[v]? voice [vɒɪs] n. 声音 love [lʌv] n. 恋爱 leave [liːv] vt. 离开 very ['ver ...

  4. Anaconda安装及PyCharm环境配置

    1. Anaconda下载 Anaconda 官方下载链接: https://www.continuum.io/downloads 根据自己的系统选择下载32位还是64位. 2. 进入下载目录 如果没 ...

  5. Oracle 11G R2 用exp无法导出空表解决方法

    四.  Oracle 10g以后增加了expdp和impdp工具,用此工具也可以导出空的表 oracleexpdp/impdp 用法详解 1)  创建逻辑目录,该命令不会在操作系统创建真正的目录,最好 ...

  6. linux HBA 卡驱动安装

    系统环境操作系统 : RHEL5.0设备 DL580G5  HBA 卡:Qlogic 2343连接存储: EVA8100---------------------------------------- ...

  7. linux + nginx 的配置优化

    linux 关于TCP/IP 的优化配置  配置文件/etc/sysctl.conf    修改完文件生效的命令  /sbin/sysctl -p 如下是总结的配置内容及说明 net.ipv4.con ...

  8. BZOJ 4358 坑 莫队+线段树 死T

    这是一个坑 竟然卡nsqrt(n)logn T死 等更 //By SiriusRen #include <cmath> #include <cstdio> #include & ...

  9. sql server 清理数据库日志

    USE [master] GO ALTER DATABASE [数据库名] SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE [数据库名] SET ...

  10. Caffe Batch Normalization推导

    Caffe BatchNormalization 推导 总所周知,BatchNormalization通过对数据分布进行归一化处理,从而使得网络的训练能够快速并简单,在一定程度上还能防止网络的过拟合, ...