Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Why does function get compile without RETURN statement

UtsavMar 28 2016 — edited Mar 31 2016

Why Oracle let function(basic/nopipelined) without RETURN compile, and throws error in execution.

As we know pipelined function doesn't require Return, because of its working and for best programming practice we write it.

But below is not the case so why does it get compile, is there something else expected by Oracle.

Please guide/help me to dissect this behaviour.

SQL> create or replace function fn_compile

  2  return number

  3  is

  4  Begin

  5     null;  --Nothing to do

  6  Exception

  7     when others then

  8     raise_application_error(-20001,SQLERRM);

  9  End;

10  /

Function created.

SQL> -- Why does above function get sucessfully compiled. It is not pipelined though

SQL> -- Now, execution will throw error

SQL> select fn_compile from dual;

select fn_compile from dual

       *

ERROR at line 1:

ORA-06503: PL/SQL: Function returned without value

ORA-06512: at "POCUSER.FN_COMPILE", line 5

This post has been answered by Billy Verreynne on Mar 29 2016
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 28 2016
Added on Mar 28 2016
12 comments
5,784 views