独立管道函数调用另一个独立管道函数

时间:2020-04-05 12:22:37

标签: oracle plsql pipelined-function

我想编写两个独立的流水线函数,这意味着在PL / SQL包之外:

create or replace function fn_test_1 
return sys.DBMS_DEBUG_VC2COLL pipelined -- ODCIVARCHAR2LIST 
AS
BEGIN
  FOR l_row in ( ... )
  LOOP
    PIPE ROW('text');
    PIPE ROW('other text');
    PIPE ROW(strings_concatenated);
  END LOOP;
END;
/

create or replace function fn_test_2 
return sys.DBMS_DEBUG_VC2COLL pipelined -- ODCIVARCHAR2LIST 
AS
BEGIN
  FOR l_row in ( select column_value as line from TABLE( fn_test_1 ) )
  LOOP
    PIPE ROW(l_row);
  END LOOP;
END;
/

fn_test_1成功编译并且可以正常工作。但是,由于以下原因,我无法编译fn_test_2

PLS-00382: expression is of wrong type

我什至可以编写一个独立的流水线函数,一个调用另一个函数吗?

1 个答案:

答案 0 :(得分:1)

您将返回一个游标,而不是它所具有的值,请使用以下命令:

create or replace function fn_test_2 
return sys.DBMS_DEBUG_VC2COLL pipelined -- ODCIVARCHAR2LIST 
AS
BEGIN
  FOR l_row in ( select column_value as line from TABLE( fn_test_1 ) )
  LOOP
    PIPE ROW(l_row.line);
  END LOOP;
END;
/