Skip to main content

Avoid initializing variables using functions in the declaration section

ZPA rule for PL/SQL and Oracle SQL · VariableInitializationWithFunctionCall

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

Examples​

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;