G-4210: Try to use CASE rather than an IF statement with multiple ELSIF paths.
Major
Maintainability, Testability
Reason
IF
statements containing multiple ELSIF
tend to become complex quickly.
Example (bad)
DECLARE
l_color VARCHAR2(7 CHAR);
BEGIN
IF l_color = constants_up.co_red THEN
my_package.do_red();
ELSIF l_color = constants_up.co_blue THEN
my_package.do_blue();
ELSIF l_color = constants_up.co_black THEN
my_package.do_black();
END IF;
END;
/
Example (good)
DECLARE
l_color types_up.color_code_type;
BEGIN
CASE l_color
WHEN constants_up.co_red THEN
my_package.do_red();
WHEN constants_up.co_blue THEN
my_package.do_blue();
WHEN constants_up.co_black THEN
my_package.do_black();
ELSE NULL;
END CASE;
END;
/