G-7120
🆓Warning
Always add the name of the program unit to its end keyword.
Reason
It's a good alternative for comments to indicate the end of program units, especially if they are lengthy or nested.
Example
Non-Compliant Example
create or replace package body employee_api is
function employee_by_id(in_employee_id in integer) -- dbLinter ignore(G-7460) non-deterministic function
return employees%rowtype is
co_employee_id constant employees.employee_id%type := in_employee_id;
r_employee employees%rowtype;
begin
select *
into r_employee
from employees
where employee_id = co_employee_id;
return r_employee;
exception
when no_data_found then
null;
when too_many_rows then
raise;
end;
end;
/Issues
| Line | Column | Message |
|---|---|---|
| 18 | 4 | |
| 19 | 1 |
Compliant Solution - ★★★★★
create or replace package body employee_api is
function employee_by_id(in_employee_id in integer) -- dbLinter ignore(G-7460) non-deterministic function
return employees%rowtype is
co_employee_id constant employees.employee_id%type := in_employee_id;
r_employee employees%rowtype;
begin
select *
into r_employee
from employees
where employee_id = co_employee_id;
return r_employee;
exception
when no_data_found then
null;
when too_many_rows then
raise;
end employee_by_id;
end employee_api;
/Parameters
Use parameters to customize the rule to your needs.
| Parameter | Description | Default Value |
|---|---|---|
| DisableAllQuickFix | Comma-separated list of rules for which a quick fix should not be applied to all the problems in a file. | Core G-3130 |
References
- same as Trivadis G-7120