Oracle Pipelined Function
建立一個測試表:
create table t(id,owner,object_id) as
select rownum,owner,object_id from all_objects;
建立必要的型別:
create type typ_test is object(
id number,
owner varchar2(50),
object_id number
);
create type typ_test_tab is table of typ_test;
建立儲存過程:
CREATE OR REPLACE FUNCTION pipe_func RETURN typ_test_tab
PIPELINED IS
CURSOR cur_t IS
SELECT * FROM t;
TYPE tab_id IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
TYPE tab_owner IS TABLE OF t.owner%TYPE INDEX BY PLS_INTEGER;
TYPE tab_objectid IS TABLE OF t.object_id%TYPE INDEX BY PLS_INTEGER;
v_ids tab_id;
v_owners tab_owner;
v_objs tab_objectid;
BEGIN
OPEN cur_t;
LOOP
FETCH cur_t BULK COLLECT
INTO v_ids, v_owners, v_objs LIMIT 10000;
EXIT WHEN cur_t%NOTFOUND;
FOR i IN 1 .. v_ids.count LOOP
PIPE ROW(typ_test(v_ids(i), v_owners(i), v_objs(i)));
END LOOP;
END LOOP;
CLOSE cur_t;
RETURN;
END pipe_func;
呼叫:
SELECT * FROM TABLE(CAST(pipe_func AS typ_test_tab)) WHERE id = 1
SELECT * FROM TABLE(pipe_func) WHERE id = 1
經測試,以上兩種方式呼叫貌似都可行.
可以參考:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8520577/viewspace-769215/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Multi-table insert using pipelined functionFunction
- Pipelined table function statistics and dynamic samplingFunction
- Oracle Pipelined Table(轉)Oracle
- Oracle Pipelined Table FunctionsOracleFunction
- Oracle Pipelined Table Functions(轉)OracleFunction
- oracle function overviewOracleFunctionView
- Oracle Table FunctionOracleFunction
- oracle function powerOracleFunction
- Pipelined FunctionsFunction
- oracle INTERNAL_FUNCTIONOracleFunction
- Oracle Deterministic FunctionOracleFunction
- Oracle 的管道化表函式(Pipelined Table) 轉Oracle函式
- oracle function函式castOracleFunction函式AST
- BIRT呼叫oracle function薦OracleFunction
- a demo function of oracle for AKingFunctionOracle
- Oracle基礎之function使用OracleFunction
- oracle create function 例項2OracleFunction
- Oracle Profile and PASSWORD_VERIFY_FUNCTIONOracleFunction
- pipelined函式例項函式
- 構建oracle function的小示例OracleFunction
- Oracle Date Function 講解和事例OracleFunction
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- improving performance with pipelined table functionsORMFunction
- plsql 除錯 pipelined 函式SQL除錯函式
- Oracle vs PostgreSQL Develop(28) - function overloadOracleSQLdevFunction
- oracle11中的char_functionOracleFunction
- Oracle replace function to delete sub-stringOracleFunctiondelete
- oracle create function的兩個例項OracleFunction
- Oracle的pipelined函式實現高效能大資料處理Oracle函式大資料
- ORACLE HANDBOOK系列之一:Oracle分析函式(Analytic Function)Oracle函式Function
- Oracle vs PostgreSQL Develop(24) - subquery with agg functionOracleSQLdevFunction
- Oracle Common Function Library 參考文件OracleFunction
- ORACLE FUNCTION函式中DETERMINISTIC測試OracleFunction函式
- Oracle Reporting 1 - Ratio_to_Report FunctionOracleFunction
- Oracle Date Function 講解和事例【Blog 搬家】OracleFunction
- Oracle procedure,package,function,triger 閃回 恢復OraclePackageFunction
- $(function(){})與(function($){....})(jQuery)的區別FunctionjQuery
- JavaScript FunctionJavaScriptFunction