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

Viewed 134

I have simple oracle function

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;

if I compile it - it compiles successfully. but when I run from PLSQL Developer SQL Window

 BEGIN abs.test_func(5); END;

it I gets the following errors

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

What's wrong with my function ?

1 Answers

Your create function code looks good, however you are not invoking the function properly. A function returns something, that you must either select, assign, print, or evaluate.

Here are a few examples of valid function calls:

-- 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

Related