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. 字节与字符_字节流与字符流_ASCII与Unicode_GB2312_GBK_GB18030_BIG-5

    字节(Byte):通常将可表示经常使用英文字符8位二进制称为一字节. 一个英文字母(不分大写和小写)占一个字节的空间,一个中文汉字占两个字节的空间. 符号:英文标点2占一个字节,中文标点占两个字节. ...

  2. Docker推出了Docker云,给大家介绍下哈!

    Docker推出了Docker云,给大家介绍下哈. 收到了Docker官网的邮件邀请,他们推出了Docker云:https://cloud.docker.com 账号信息栏目下有: 云提供商:眼下支持 ...

  3. sql不显示反复列

    在报表里,基本上都能够把反复的资料不显示,在SQL里怎么才干做到例如以下情况呢? a 10 a 20 b 30 b 40 b 50 显示为: a 10 20 b 30 40 50 SQL 例如以下: ...

  4. 2015.04.24,外语,读书笔记-《Word Power Made Easy》 12 “如何奉承朋友” SESSION 34

    1.no fatigue indefatigable([indi'fætigәb(ә)l] adj. 不知疲倦的)来自faigue,in-是反义词缀:后缀-able表示able to be,因此ind ...

  5. webrtc所有平台下载编译步骤详细说明

    webrtc所有平台下载编译步骤详细说明 1.安装depot tools Windows:国外下载:https://storage.googleapis.com/chrome-infra/depot_ ...

  6. Hessian实例

    简述Hessian Hessian是一个由Caucho Technology开发的轻量级RPC框架,由于它使用二进制RPC协议,所以它更快.更简单,很适合于发送二进制数据(访问官网): 在进行基于He ...

  7. linux下通用Makefile写法

    linux编译多个源文件的程序比较麻烦,这下就需要通用的Makefile了,编译的时候执行一下make命令就OK,下面介绍通用makfile的写法. 假设现在有以下源文件:file1.h file1. ...

  8. vue入门--简单嵌套路由的一个路径小问题

    假设现在有一个项目,刚进去要显示main页面下的contorl页面,那么路由里面的初级路由应该是{main和err},这两个是同一级,然后{control和set}是main下的子路由,foot是这两 ...

  9. DB2查看表空间和增加表空间容量

    Db2 connect to xxx Db2 “LIST TABLESPACES SHOW DETAIL” Tablespace ID = 7 Name = TSASNAA Type = Databa ...

  10. Caffe_Scale层解析

    Caffe Scale层解析 前段时间做了caffe的batchnormalization层的解析,由于整体的BN层实现在Caffe是分段实现的,因此今天抽时间总结下Scale层次,也会后续两个层做合 ...