這裏有兩個流水線功能包:管道函數調用另一個管道函數
create or replace type tq84_line as table of varchar2(25);
/
create or replace package tq84_pipelined as
function more_rows return tq84_line pipelined;
function go return tq84_line pipelined;
end tq84_pipelined;
/
螞蟻相應的包體:
create or replace package body tq84_pipelined as
function more_rows return tq84_line pipelined is
begin
pipe row('ist');
pipe row('Eugen,');
return;
end more_rows;
function go return tq84_line pipelined is
begin
pipe row('Mein');
pipe row('Name');
/* start */
for next in (
select column_value line from table(more_rows)
)
loop
pipe row(next.line);
end loop;
/* end */
pipe row('ich');
pipe row('weiss');
pipe row('von');
pipe row('nichts.');
end go;
end tq84_pipelined;
/
重要的是,去排序電話more_rows
與 /* start */
和/* end */
我可以使用包如下:
select * from table(tq84_pipelined.go);
這是所有罰款和花花公子,但我希望我能與more_rows
一個簡單的調用替換/* start */
和/* end */
之間的界線。
但是,這顯然是不可能的,因爲它生成了一個PLS-00221:'MORE_ROWS'不是一個過程,或者是未定義的。
所以,我的問題是:真的沒有辦法捷徑循環?
編輯
顯然,從到目前爲止的答案,我的問題是不明確的。
包裝,如上所述的作品。
但我很困擾標記/* start */
和/* end */
之間的6(即:SIX)行。我想用一條線代替它們。但我沒有找到任何方式做到這一點。
感謝您的回覆。但它並不能幫助我的'問題',因爲在這個構造中,我不僅有'for ...循環......結束循環'結構,但也是一個額外的'批量收集'。我的意思是,這不是一個問題,因爲我可以忍受它,但是我認爲它在視覺上更具吸引力,只需一行簡單的調用即可獲得更多的行,而無需進一步的循環,而不需要更多的循環。 – 2010-05-07 02:36:51