oracle管道函數是一類特殊的函數,oracle管道函數返回值類型必須為集合
如果需要在客戶端實時的輸出函數執行過程中的一些信息,在oracle9i以后可以使用管道函數(pipeline function)。
關鍵字PIPELINED表明這是一個oracle管道函數,oracle管道函數的返回值類型必須為集合
--創建一個集合接受返回的值1st.create or replace type type_split as table of varchar2(4000);--創建管道函數create or replace function split(p_string varchar2, p_sep varchar2 := ',') return type_split pipelined--dbms_output輸出的信息,需要在服務器執行完整個函數后一次性的返回給客戶端--pipelined 表明這是一個管道函數,oracle管道函數的返回值類型必須為集合--PIPE ROW語句被用來返回該集合的單個元素asv_string varchar2(4000) := p_string;idx Number;beginloop--idx為第一個,所在的位置idx := instr(v_string, p_sep);if idx > 0 then--,前面的數據加入Row/,后面的數據為下個循環使用的字符串pipe row(substr(v_string, 1, idx - 1));v_string := substr(v_string, idx + length(p_sep));elseexit;end if;end loop;--執行完后需returnreturn ;end;test:select a.cust_po,b.column_value proqepi from ( select cust_po,proqepi from cux_custpo_info_t where cust_po='PX90806001-4') a,(table(split(a.proqepi,','))) b
測試成功。
總結
以上所述是小編給大家介紹的oracle管道函數的用法(一行拆為多行),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!
新聞熱點
疑難解答