PL/SQL表---table()函数用法
?http://www.itpub.net/thread-617298-1-1.html
?
PL/SQL表---table()函數(shù)用法:
利用table()函數(shù),我們可以將PL/SQL返回的結(jié)果集代替table。
simple example:
1、table()結(jié)合數(shù)組:
*/
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));
/*
2、table()結(jié)合PIPELINED函數(shù):
*/
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));
/*
3、table()結(jié)合系統(tǒng)包:
*/
create table test (id varchar2(20));
insert into test values('1');
commit;
explain plan for select * from test;
select * from table(dbms_xplan.display);
?
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的PL/SQL表---table()函数用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle 数组类型
- 下一篇: JDBC query VARRAY on