2

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 ?

0xdb
  • 3,539
  • 1
  • 21
  • 37
David
  • 4,332
  • 13
  • 54
  • 93

1 Answers1

5

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

GMB
  • 216,147
  • 25
  • 84
  • 135