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 ...
随机推荐
- Python+Django+SAE系列教程16-----cookie&session
本章我们来解说cookie和session ,这两个东西相信大家一定不陌生,概念就不多讲了,我们直接来看其使用方法,首先是cookie,我们在view中加入三个视图,一个是显示cookie的,一个是设 ...
- 连载:面向对象葵花宝典:思想、技巧与实践(30) - SRP原则
前面具体阐述了"高内聚低耦合"的整体设计原则.但怎样让设计满足这个原则,并非一件简单的事情.幸好各位前辈和大牛已经帮我们归纳总结出来了,这就是"设计原则"和&q ...
- 【MySQL】MySQL删除匿名用户,保证登录安全
博客地址已迁往 www.virtclouds.com 原文地址 http://www.virtclouds.com/538.html 很多MySQL程序都会带有匿名登录的功能. 在刚刚安装完MySQL ...
- Makefile经典教程(转)
转自:http://blog.csdn.net/ruglcc/article/details/7814546/ makefile很重要 什么是makefile?或许很多Winodws的程序员都不知道这 ...
- Android 多个APK共享数据
Android给每个APK进程分配一个单独的用户空间,其manifest中的userid就是对应一个Linux用户(Android 系统是基于Linux)的.所以不同APK(用户)间互相访问数据默认是 ...
- 分布式memcache
使用多台memchache服务器,形成memchache集群.目的是为了提升memchache所能使用的硬件资源数量.多台memcached服务器之间不相互通讯.分布式算法由客户端实现,(php来说, ...
- Route学习笔记
前言 UrlRoutingModule.class:这块的代码关联了上一篇中路由部分的一个详细说明 一:Route的讲解 1. 路由模板匹配 添加路由: MapRoute 剔除的路由:IgnoreRo ...
- 微信小程序 | canvas绘图
1.新的尺寸单位 rpx rpx(responsive pixel): 可以根据屏幕宽度进行自适应. 规定屏幕宽为750rpx.如在 iPhone6 上,屏幕宽度为375px,共有750个物理像素,则 ...
- 懒人npm运行和打包命令
源码: @echo off&setlocal EnableDelayedExpansion & color 3e :start title npm 常用命令 by:ceet@vip.q ...
- iOS11中navigationBar上 按钮图片设置frame无效 不受约束 产生错位问题 解决
问题描述: 正常样式: 在iOS 11 iPhone X上显示效果: 观察顶部navBar上的左侧按钮 在ios 11 上 这个按钮的图片不受设置的尺寸约束,按其真实大小展示,造成图片错位,影响界 ...