当我尝试编译以下代码时,我收到错误:
[错误] PLS-00382(15:17):PLS-00382:表达式类型错误
代码
CREATE OR REPLACE FUNCTION test_pipe
RETURN SYS.odcivarchar2list
PIPELINED
AS
CURSOR cEmploee
IS
SELECT first_name FROM employee;
BEGIN
FOR i IN cEmploee
LOOP
DBMS_OUTPUT.put_line (i.first_name);
PIPE ROW (sys.odcivarchar2list (i.first_name));
EXIT WHEN cEmploee%NOTFOUND;
END LOOP;
RETURN;
END;
/
任何人都可以解释SYS.odcivarchar2list
是否适用于PIPELINED功能。让我知道如何解决这个问题。感谢。
答案 0 :(得分:2)
'var'的类型应该是varchar2:
CREATE OR REPLACE FUNCTION test_pipe
RETURN SYS.odcivarchar2list
PIPELINED
AS
CURSOR cEmploee
IS
SELECT first_name FROM employee;
var employee.first_name%type;
BEGIN
FOR i IN cEmploee
LOOP
DBMS_OUTPUT.put_line (i.first_name);
var := i.first_name;
PIPE ROW (var);
EXIT WHEN cEmploee%NOTFOUND;
END LOOP;
RETURN;
END;
/
select * from table(test_pipe)