Skip to main content

Avoid initializing variables using functions in the declaration section

If your initialization fails you will not be able to handle the error in your exceptions block.

Noncompliant Code Example

DECLARE
employee_name emp.name%TYPE := get_employee_name(id => 5);
BEGIN
...
END;

Compliant Solution

DECLARE
employee_name emp.name%TYPE;
BEGIN
employee_name := get_employee_name(id => 5);
...
END;