【发布时间】:2021-06-20 19:49:39
【问题描述】:
create or replace function fn_master(col_name VARCHAR2) return master_file pipelined
Is
TYPE MYMASTER_FILE IS RECORD (
id NUMBER(5),
name VARCHAR2(101),
school varchar2(2000)
);
TYPE MASTER_FILE_ARRAY IS TABLE OF MYMASTER_FILE
INDEX BY PLS_INTEGER;
l_info MASTER_FILE_ARRAY;
begin
execute immediate 'select id, name, school from x_table where ' || col_name || '= ''xxxxxx'' '
BULK COLLECT INTO l_info;
FOR i IN 1 .. l_info.COUNT
LOOP
PIPE row(master_file(
l_info(i).id,
l_info(i).name ,
l_info(i).school
));
END LOOP;
end fn_master;
这是我创建的函数,用于接受该表中的列并打印返回的行。为了在堆栈溢出时将其呈现在此处,我将其简化了。
当我尝试编译时出现错误
PLS-00630: pipelined functions must have a supported collection return type
但是当我添加一个返回子句时它告诉我
PLS-00633: RETURN statement in a pipelined function cannot contain an expression
PLS-00382: expression is of wrong type
PLS-00630: pipelined functions must have a supported collection return type
你们能帮我解决这个问题吗
【问题讨论】:
-
是我接近函数的方式,正确的方式吗?
标签: oracle plsql oracle10g oracle-sqldeveloper oracle18c