【发布时间】:2010-05-07 09:50:05
【问题描述】:
这是一个包含两个流水线函数的包:
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;
/
ant对应的包体:
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;
/
重要的是 go 某种调用 more_rows 与 for next in ... 在 /* start */ 和 /* end */ 之间
我可以按如下方式使用包:
select * from table(tq84_pipelined.go);
这一切都很好,很花哨,但我希望我可以用简单的more_rows 调用替换/* start */ 和/* end */ 之间的行。
但是,这显然是不可能的,因为它会产生 PLS-00221: 'MORE_ROWS' is not an procedure or is undefined。
那么,我的问题是:真的没有办法缩短循环吗?
编辑
显然,从目前的答案来看,我的问题并不清楚。
如前所述,该软件包有效。
但我对标记 /* start */ 和 /* end */ 之间的 6 行(即:6 行)感到困扰。我想用一行替换这些。但是我还没有找到任何方法。
【问题讨论】: