PL/SQL表---table()函数用法
/*

PL/SQL表---table()函数用法:
利用table()函数,我们可以将PL/SQL返回的结果集代替table。

oracle内存表在查询和报表的时候用的比较多,它的速度相对物理表要快几十倍。

simple example:

1、table()结合数组:

*/

create or replace type t_test as object(
id integer,
rq date,
mc varchar2(60)
);

create or replace type t_test_table as table of t_test;

create or replace function f_test_array(n in number default null) return t_test_table
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
v_test.extend();
v_test(v_test.count) := t_test(i,sysdate,'mc'||i);
end loop;
return v_test;
end f_test_array;
/

select * from table(f_test_array(10));

select * from the(select f_test_array(10) from dual);

/*

2、table()结合PIPELINED函数:

*/

create or replace function f_test_pipe(n in number default null) return t_test_table PIPELINED
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
pipe row(t_test(i,sysdate,'mc'||i));
end loop;
return;
end f_test_pipe;
/

select * from table(f_test_pipe(20));

select * from the(select f_test_pipe(20) from dual);

/*

3、table()结合系统包:

*/

create table test (id varchar2(20));
insert into test values('1');
commit;
explain plan for select * from test;
select * from table(dbms_xplan.display);

PL/SQL表---table()函数用法
/*

PL/SQL表---table()函数用法:
利用table()函数,我们可以将PL/SQL返回的结果集代替table。

oracle内存表在查询和报表的时候用的比较多,它的速度相对物理表要快几十倍。

simple example:

1、table()结合数组:

*/

create or replace type t_test as object(
id integer,
rq date,
mc varchar2(60)
);

create or replace type t_test_table as table of t_test;

create or replace function f_test_array(n in number default null) return t_test_table
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
v_test.extend();
v_test(v_test.count) := t_test(i,sysdate,'mc'||i);
end loop;
return v_test;
end f_test_array;
/

select * from table(f_test_array(10));

select * from the(select f_test_array(10) from dual);

/*

2、table()结合PIPELINED函数:

*/

create or replace function f_test_pipe(n in number default null) return t_test_table PIPELINED
as
v_test t_test_table := t_test_table();
begin
for i in 1 .. nvl(n,100) loop
pipe row(t_test(i,sysdate,'mc'||i));
end loop;
return;
end f_test_pipe;
/

select * from table(f_test_pipe(20));

select * from the(select f_test_pipe(20) from dual);

/*

3、table()结合系统包:

*/

create table test (id varchar2(20));
insert into test values('1');
commit;
explain plan for select * from test;
select * from table(dbms_xplan.display);

oracle table()函数的更多相关文章

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

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

  2. Oracle中使用Table()函数解决For循环中不写成 in (l_idlist)形式的问题

    转: Oracle中使用Table()函数解决For循环中不写成 in (l_idlist)形式的问题 在实际PL/SQL编程中,我们要对动态取出来的一组数据,进行For循环处理,其基本程序逻辑为: ...

  3. Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace

    Oracle正则表达式函数:regexp_like.regexp_substr.regexp_instr.regexp_replace   --去掉所有特殊字符,只剩字母  SELECT REGEXP ...

  4. Oracle中函数/过程返回结果集的几种方式

    原文 Oracle中函数/过程返回结果集的几种方式 Oracle中函数/过程返回结果集的几种方式:    以函数return为例,存储过程只需改为out参数即可,在oracle 10g测试通过.    ...

  5. 十、oracle 常用函数

    一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...

  6. oracle 常用函数汇总

    一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...

  7. Oracle分析函数——函数列表

    --------------聚合函数 SUM :该函数计算组中表达式的累积和 MIN :在一个组中的数据窗口中查找表达式的最小值 MAX :在一个组中的数据窗口中查找表达式的最大值 AVG :用于计算 ...

  8. Oracle中函数/过程返回多个值(结果集)

    Oracle中函数/过程返回结果集的几种方式: 以函数return为例,存储过程只需改为out参数即可,在oracle 10g测试通过. (1) 返回游标: return的类型为:SYS_REFCUR ...

  9. Oracle开窗函数笔记及应用场景

    介绍Oracle的开窗函数之前先介绍一下分析函数,因为开窗函数也属于分析函数 分析函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是:对于每个组返回多行,而聚合函数对于每个组只返回一行. 上面是 ...

随机推荐

  1. C++ 读 ,写 文件

    1 //文件操作 2 //文本文件 读 ,写文件 3 4 #include <iostream> 5 #include <string> 6 #include<fstre ...

  2. WPF(MVVM) 利用资源字典实现中英文动态切换

    1.首先新建两个字典文件en-us.xaml.zh-cn.xaml.定义中英文的字符串在这里面. 2.将两个资源字典添加到App.xaml中,这里注意下,因为两个字典中有同样字符,如果没有动态更改,默 ...

  3. 【笔记】SVM思想解决回归问题

    使用svm思想解决回归问题 使用svm思想解决是如何解决回归问题,其中回归问题的本质就是找一条线,能够最好的拟合数据点 怎么定义拟合就是回归算法的关键,线性回归算法就是让预测的直线的MSE的值最小,对 ...

  4. javaWeb之Maven

    为什么要学这个技术? 在JavaWeb开发中,需要使用大量的jar包 如何能够让一个工具自动帮我们导入和配置这个jar包 一.Maven项目架构管理工具 核心思想:约定大于配置 有约束,不要去违反 M ...

  5. 三个线程按循序一个打印A一个打印B一个打印C 循环打印?

    第一种 public static volatile int flag = 1; public static void printABC1(){ Thread t1 = new Thread(() - ...

  6. 0x800b010a 证书

    无论是装微软的什么应用,只要报这个错误,下载这个证书: http://download.microsoft.com/download/2/4/8/248D8A62-FCCD-475C-85E7-6ED ...

  7. npm压缩js文件

    参考:https://blog.csdn.net/msy_msy/article/details/78261383 1.压缩单个js文件 cnpm install uglify-js -g 安装 1& ...

  8. springboot中添加事务注解

    1.首先在service层中的方法前添加@Transactional @Service public class UserService { @Autowired private UserMapper ...

  9. commandBinding 的命令

    <Window x:Class="WpfApplication1.Window29" xmlns="http://schemas.microsoft.com/win ...

  10. PE分析

    1 #include<windows.h> 2 #include<RichEdit.h> 3 #include "resource.h" 4 5 6 7 B ...