G-9030: Try to define a default value on conversion errors.

Minor

Maintainability, Reliability, Testability

Reason

When converting from strings to other datatypes using a conversion function that supports the default ... on conversion error clause, it is a good idea to use this clause to avoid getting an error raised on bad input. The exception can be when you explicitly want an error to be raised to catch and process it in a later exception handler.

 1 2 3 4 5 6 7 8 9 create package body employee_api is procedure set_dob (in_employee_id in employees.employee_id%type, in_dob_str in varchar2) begin update employee set date_of_birth = to_date(in_dob_str, 'YYYY-MM-DD') where employee_id = in_employee_id; end set_dob; end employee_api; / 
 1 2 3 4 5 6 7 8 9 create package body employee_api is procedure set_dob (in_employee_id in employees.employee_id%type, in_dob_str in varchar2) begin update employee set date_of_birth = to_date(in_dob_str default null on conversion error, 'YYYY-MM-DD') where employee_id = in_employee_id; end set_dob; end employee_api; /