1

我有一个管道功能

row_t AS OBJECT(...);
table_t IS TABLE OF row_t
func_a RETURN table_t PIPELINED AS ...

另一个函数将row_t作为参数:

func_b(row_in row_t)

现在,在一个过程中,我想将每一行从管道函数传递到func_b

FOR c IN (SELECT * FROM TABLE(func_a()))
LOOP
    -- The following code gives compilation error,
    -- How do I convert c to row_t type???
    some_var := func_b(c);
    ...
END LOOP;

有什么建议吗?提前谢谢大家!

4

1 回答 1

1
create or replace type row_t as object(a number, b number);

create or replace type table_t is table of row_t;

create or replace function func_a return table_t pipelined as
    v_row_t row_t := row_t(1, 2);
begin
    pipe row (v_row_t);
end;
/

create or replace function func_b(row_in row_t) return number as
begin
    return 3;
end;
/

declare
    v_row_t row_t;
    v_result number;
begin
    for c in
    (
        select * from table(func_a())
    ) loop
        v_result := func_b(row_t(c.a, c.b));
    end loop;
end;
/
于 2013-07-08T18:05:49.370 回答