This document discusses conditional control statements in PL/SQL, specifically IF and ELSIF statements. It provides an example of rewriting multiple IF statements using ELSIF, noting that ELSIF offers more efficient implementation when conditions are mutually exclusive. The document recommends using ELSIF for mutually exclusive conditions and simplifying IF statements with boolean expressions when possible.
1 of 6
More Related Content
PL/SQL Example for IF .. ELSIF
1. PL/SQL Example #1 Two types of conditional control in PL/SQL: IF statements ELSIF statements
2. IF Example? Procedure process_task (task_in IN INTEGER) IS BEGIN IF task_in = 1 THEN Task_line1; END IF; IF task_in = 2 THEN Task_line2; END IF; … IF task_in = 20 THEN Task_line20; END IF; END;
3. Rewrite! Procedure process_task (task_in IN INTEGER) IS BEGIN IF task_in = 1 THEN Task_line1; ELSIF task_in = 2 THEN Task_line2; … ELSIF task_in = 20 THEN Task_line20; END IF; END;
4. ELSIF Statement If one condition is TRUE, no others can be TRUE. ELSIF offers the most efficient implementation for processing mutually exclusive clauses. When one clause evaluates to TRUE, all subsequent classes are ignored.
5. Good Points! Use ELSIF with mutually exclusive clauses Use IF…ELSIF only to test a single, simple condition. Replace and simplify IF statements with Boolean expressions.