Skip to content

Commit

Permalink
Fix violations of G-1050, G-8310, G-9040
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippSalvisberg committed Sep 1, 2023
1 parent 4639692 commit d2ea4e1
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions docs/4-language-usage/9-function-usage/g-9030.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ When converting from strings to other datatypes using a conversion function that

``` sql
create or replace package body employee_api is
procedure set_dob(in_employee_id in employees.employee_id%type
,in_dob_str in varchar2) is
procedure set_dob(
in_employee_id in employees.employee_id%type
,in_dob_str in varchar2
) is
co_employee_id constant employees.employee_id%type := in_employee_id;
co_dob_str constant type_up.date_string := in_dob_str;
begin
update employees
set date_of_birth = to_date(in_dob_str,'YYYY-MM-DD')
where employee_id = in_employee_id;
set date_of_birth = to_date(co_dob_str,'FXYYYY-MM-DD' -- NOSONAR G-1050 must be a literal
)
where employee_id = co_employee_id;
end set_dob;
end employee_api;
/
Expand All @@ -30,12 +35,19 @@ end employee_api;

``` sql
create or replace package body employee_api is
procedure set_dob(in_employee_id in employees.employee_id%type
,in_dob_str in varchar2) is
procedure set_dob(
in_employee_id in employees.employee_id%type
,in_dob_str in varchar2
) is
co_employee_id constant employees.employee_id%type := in_employee_id;
co_dob_str constant type_up.date_string := in_dob_str;
begin
update employees
set date_of_birth = to_date(in_dob_str default null on conversion error,'YYYY-MM-DD')
where employee_id = in_employee_id;
set date_of_birth = to_date(
co_dob_str default null on conversion error
,'FXYYYY-MM-DD' -- NOSONAR G-1050 must be a literal
)
where employee_id = co_employee_id;
end set_dob;
end employee_api;
/
Expand Down

0 comments on commit d2ea4e1

Please sign in to comment.