Oracle 函数编译成功但在执行 PLS-00221 时抛出错误:不是过程或未定义

Dav*_*vid 2 sql oracle plsql stored-procedures sql-function

我有简单的 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;
Run Code Online (Sandbox Code Playgroud)

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

 BEGIN abs.test_func(5); END;
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

ORA-06550: line1, column8;
PLS-00221: 'TEST_FUNC' is not a procedure or is undefined
ORA-06550: line1, column8;
PL/SQL: Statement ignored
Run Code Online (Sandbox Code Playgroud)

我的功能有什么问题?

GMB*_*GMB 5

您的create function代码看起来不错,但是您没有正确调用该函数。函数返回某些内容,您必须对其进行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 |
Run Code Online (Sandbox Code Playgroud)

DB Fiddle 上的演示