Oracle 函数编译成功但在执行时抛出错误 PLS-00221: is not a procedure or is undefined

Oracle function compiles successfully but throws error while executing PLS-00221: is not a procedure or is undefined

我有简单的 oracle 函数

create or replace function abs.test_func(test_in in number)
return number
is
   test_out number ;
BEGIN
test_out:=test_in;
RETURN test_out;
END;

如果我编译它 - 它编译成功。 但是当我 运行 来自 PLSQL Developer SQL Window

 BEGIN abs.test_func(5); END;

我收到以下错误

ORA-06550: line1, column8;
PLS-00221: 'TEST_FUNC' is not a procedure or is undefined
ORA-06550: line1, column8;
PL/SQL: Statement ignored

我的函数有什么问题?

您的 create function 代码看起来不错,但是您没有正确地 调用 函数。一个函数 returns 某些东西,您必须 select、赋值、打印或求值。

以下是有效函数调用的几个示例:

-- print the return value
begin
    dbms_output.put_line(test_func(5));
end;
/

1 rows affected

dbms_output:
5


-- select the return value
select test_func(5) from dual;

| TEST_FUNC(5) |
| -----------: |
|            5 |

Demo on DB Fiddle