ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
PL/SQL Example #1 Two types of conditional control in PL/SQL:  IF statements  ELSIF statements
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;
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;
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.
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.
Q&A Use IF wisely? Next Week Case. Thank You!

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.
  • 6. Q&A Use IF wisely? Next Week Case. Thank You!