ALTER SESSION SET plsql_warnings = 'enable:all'
Statement processed.
CREATE OR REPLACE FUNCTION my_function
RETURN BOOLEAN AUTHID DEFINER
IS
BEGIN
RETURN FALSE;
END;
Function created.
CREATE OR REPLACE FUNCTION my_date
RETURN DATE AUTHID DEFINER
IS
BEGIN
RETURN SYSDATE - 10;
END;
Function created.
CREATE OR REPLACE FUNCTION no_return (check_in IN BOOLEAN)
RETURN VARCHAR2
AS
BEGIN
IF check_in
THEN
RETURN 'abc';
ELSE
DBMS_OUTPUT.put_line ('Here I am, here I stay');
IF my_function ()
THEN
RETURN 'def';
ELSIF SYSDATE < my_date ()
THEN
RETURN 'qrs';
ELSE
DBMS_OUTPUT.put_line ('Hello!');
END IF;
END IF;
END no_return;
Warning: FUNCTION NO_RETURN Line/Col: 1/1 PLW-05005: subprogram NO_RETURN returns without value at line 21 Line/Col: 1/1 PLW-05018: unit NO_RETURN omitted optional AUTHID clause; default value DEFINER usedMore Details: https://docs.oracle.com/error-help/db/ora-20001
select text from user_errors
where name = 'NO_RETURN'
TEXT | PLW-05018: unit NO_RETURN omitted optional AUTHID clause; default value DEFINER used | PLW-05005: subprogram NO_RETURN returns without value at line 21 |
---|
BEGIN
DBMS_OUTPUT.put_line (no_return (FALSE));
END;
ORA-06503: PL/SQL: Function returned without value ORA-06512: at "SQL_RHMNFZMBVXMXUDWPPFNBLLUVE.NO_RETURN", line 21 ORA-06512: at line 2 ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-06503
ALTER SESSION SET plsql_warnings = 'ERROR:5005'
Here I am, here I stay
Hello!
ALTER FUNCTION no_return COMPILE
CREATE OR REPLACE FUNCTION no_return (check_in IN BOOLEAN)
RETURN VARCHAR2
AS
BEGIN
IF check_in
THEN
RETURN 'abc';
ELSE
DBMS_OUTPUT.put_line ('Here I am, here I stay');
IF check_in
THEN
RETURN 'def';
ELSIF SYSDATE IS NOT NULL
THEN
RETURN 'qrs';
ELSE
DBMS_OUTPUT.put_line ('Hello!');
RETURN 'hello';
END IF;
END IF;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END no_return;
Errors: FUNCTION NO_RETURN Line/Col: 1/1 PLS-05005: subprogram NO_RETURN returns without value at line 26More Details: https://docs.oracle.com/error-help/db/ora-24344
CREATE OR REPLACE FUNCTION no_return (check_in IN BOOLEAN)
RETURN VARCHAR2
AS
BEGIN
RETURN NULL;
EXCEPTION
WHEN OTHERS
THEN
RAISE NO_DATA_FOUND;
END no_return;
Function created.
CREATE OR REPLACE FUNCTION error5005
RETURN INTEGER
IS
BEGIN
RETURN 5;
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (-20001, 'Error 5005');
END;
Errors: FUNCTION ERROR5005 Line/Col: 1/1 PLS-05005: subprogram ERROR5005 returns without value at line 10More Details: https://docs.oracle.com/error-help/db/ora-24344
CREATE OR REPLACE FUNCTION error5005
RETURN INTEGER
IS
BEGIN
RETURN 5;
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (-20001, 'Error 5005');
END;
Errors: FUNCTION ERROR5005 Line/Col: 1/1 PLS-05005: subprogram ERROR5005 returns without value at line 10More Details: https://docs.oracle.com/error-help/db/ora-24344
CREATE OR REPLACE FUNCTION no_return (check_in IN BOOLEAN)
RETURN VARCHAR2
AS
l_return VARCHAR2 (32767);
BEGIN
IF check_in
THEN
l_return := 'abc';
ELSE
DBMS_OUTPUT.put_line ('Here I am, here I stay');
IF check_in
THEN
l_return := 'def';
ELSIF SYSDATE IS NOT NULL
THEN
l_return := 'qrs';
ELSE
DBMS_OUTPUT.put_line ('Hello!');
l_return := 'hello';
END IF;
END IF;
RETURN l_return;
EXCEPTION
WHEN OTHERS
THEN
-- In theory: log_error ();
RAISE;
END no_return;
Function created.