G-7330
🆓Error
Always assign values to OUT parameters.
Reason
Marking a parameter for output means that callers will expect its value to be updated with a result from the execution of the procedure. Failing to update the parameter before the procedure returns is surely an error.
Example
Non-Compliant Example
create or replace package body my_package is
procedure greet(
in_name in varchar2
,out_greeting out varchar2
) is
l_message types_up.text;
co_name constant employees.first_name := in_name;
co_hello constant types_up.text := 'Hello, ';
begin
l_message := co_hello || co_name;
end greet;
end my_package;
/Issues
| Line | Column | Message |
|---|---|---|
| 4 | 7 |
Compliant Solution - ★★★★★
create or replace package body my_package is
procedure greet(
in_name in varchar2
,out_greeting out varchar2
) is
co_name constant employees.first_name := in_name;
co_hello constant types_up.text := 'Hello, ';
begin
out_greeting := co_hello || co_name;
end greet;
end my_package;
/References
- same as Trivadis G-7330
- same as plsql:S4196