Oracle 中,函数如何返回结果集
来源:互联网 发布:java作用域范围 编辑:程序博客网 时间:2024/04/29 22:34
在Oracle中,用函数返回结果集有时候要用到,下面是demo:
create or replace type t_test as object
(
id integer,
create_time date,
object_name varchar2(60)
);
create or replace type t_test_table as table of t_test;
1.用数组的方式
create or replace function f_test(n in number default null)
return t_test_table as
v_test t_test_table := t_test_table();
begin
for i in 1 .. n loop
v_test.extend();
v_test(v_test.count) := t_test(i, sysdate, 'name' || i);
end loop;
return v_test;
end f_test;
/
SQL> select * from table(f_test(5));
ID CREATE_TIME OBJECT_NAME
-------- -------------- -------------
1 07-4月 -15 name1
2 07-4月 -15 name2
3 07-4月 -15 name3
4 07-4月 -15 name4
5 07-4月 -15 name5
2.用管道函数
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, 'name' || i));
end loop;
return;
end f_test_pipe;
/
SQL> select * from table(f_test_pipe(5));
ID CREATE_TIME OBJECT_NAME
---------- -------------- ----------------
1 07-4月 -15 mc1
2 07-4月 -15 mc2
3 07-4月 -15 mc3
4 07-4月 -15 mc4
5 07-4月 -15 mc5
- Oracle 中,函数如何返回结果集
- Oracle中过程/函数返回结果集
- Oracle中过程/函数返回结果集
- Oracle中过程/函数返回结果集
- Oracle中过程/函数返回结果集
- ORACLE如何返回结果集
- 函数如何返回结果集
- 如何在oracle中限制返回结果集的大小
- Oracle在存储过程中如何返回结果集
- Oracle存储过程如何返回结果集
- java调用ORACLE函数返回结果集
- java 调用oracle函数返回结果集
- ORACLE 函数返回对象类型结果集
- oracle函数返回table类型结果集
- Oracle 函数function之返回结果集
- Oracle函数返回游标,在JAVA中显示结果
- C语言中函数如何返回处理后的结果?
- Oracle table()函数查询函数返回的结果集
- 【C语言】将字符串顺序翻转,如: I am a student 转成:student a am I
- concatenate two byte arrays
- C语言实现 编写一个函数,传入a,b两个int类型的变量,返回两个值的最大公约数。
- 函数调用栈空间的分配和释放
- UITableView上拉、下拉原理
- Oracle 中,函数如何返回结果集
- 蓝桥杯:算法训练 2的次幂表示
- ARM-Linux支持并自动挂载U盘
- convert a hexadecimal string to a byte string
- html5
- 坑爹的SIGPIPE
- Ajax 学习初步
- leetcode-14 Longest Common Prefix
- 代码段