rspec/rules/S2466/plsql/rule.adoc
2022-02-04 16:28:24 +00:00

45 lines
903 B
Plaintext

Always having a ``++RETURN++`` as the last statement in a function is a good practice as it prevents the ``++ORA-06503 PL/SQL: Function returned without value++`` error.
== Noncompliant Code Example
[source,sql]
----
CREATE FUNCTION incorrectFunction RETURN PLS_INTEGER IS -- Non-Compliant
BEGIN
NULL; -- This function was expected to return a PLS_INTEGER, but did not. Will lead to ORA-06503
END;
/
BEGIN
DBMS_OUTPUT.PUT_LINE('Ret = ' || incorrectFunction2); -- ORA-06503 PL/SQL: Function returned without value
END;
/
DROP FUNCTION incorrectFunction;
----
== Compliant Solution
[source,sql]
----
CREATE FUNCTION correctFunction RETURN PLS_INTEGER IS -- Compliant
BEGIN
RETURN 42;
END;
/
DROP FUNCTION correctFunction;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]