
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
50 lines
965 B
Plaintext
50 lines
965 B
Plaintext
== Why is this an issue?
|
|
|
|
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)
|
|
|
|
=== Message
|
|
|
|
Add a "RETURN" to the end of this function.
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|