PL/SQL Example #1 <ul><li>Two types of conditional control in PL/SQL:  </li></ul><ul><ul><li>IF statements  </li></ul></ul...
IF Example? <ul><li>Procedure process_task (task_in IN INTEGER)  </li></ul><ul><li>IS  </li></ul><ul><li>BEGIN </li></ul><...
Rewrite! <ul><li>Procedure process_task (task_in IN INTEGER)  </li></ul><ul><li>IS  </li></ul><ul><li>BEGIN </li></ul><ul>...
ELSIF Statement <ul><li>If one condition is TRUE, no others can be TRUE. ELSIF offers the most efficient implementation fo...
Good Points! <ul><li>Use ELSIF with mutually exclusive clauses </li></ul><ul><li>Use IF…ELSIF only to test a single, simpl...
Q&A <ul><li>Use IF wisely? </li></ul><ul><li>Next Week Case. </li></ul><ul><li>Thank You! </li></ul>
Upcoming SlideShare
Loading in …5
×

PL/SQL Example for IF .. ELSIF

2,762 views

Published on

Design for Class to teach main points of IF .. ELSIF concepts.

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,762
On SlideShare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

PL/SQL Example for IF .. ELSIF

  1. 1. PL/SQL Example #1 <ul><li>Two types of conditional control in PL/SQL: </li></ul><ul><ul><li>IF statements </li></ul></ul><ul><ul><li>ELSIF statements </li></ul></ul>
  2. 2. IF Example? <ul><li>Procedure process_task (task_in IN INTEGER) </li></ul><ul><li>IS </li></ul><ul><li>BEGIN </li></ul><ul><li>IF task_in = 1 THEN </li></ul><ul><li>Task_line1; </li></ul><ul><li>END IF; </li></ul><ul><li>IF task_in = 2 THEN </li></ul><ul><li>Task_line2; </li></ul><ul><li>END IF; </li></ul><ul><li>… </li></ul><ul><li>IF task_in = 20 THEN </li></ul><ul><li>Task_line20; </li></ul><ul><li>END IF; </li></ul><ul><li>END; </li></ul>
  3. 3. Rewrite! <ul><li>Procedure process_task (task_in IN INTEGER) </li></ul><ul><li>IS </li></ul><ul><li>BEGIN </li></ul><ul><li>IF task_in = 1 THEN </li></ul><ul><li>Task_line1; </li></ul><ul><li>ELSIF task_in = 2 THEN </li></ul><ul><li>Task_line2; </li></ul><ul><li>… </li></ul><ul><li>ELSIF task_in = 20 THEN </li></ul><ul><li>Task_line20; </li></ul><ul><li>END IF; </li></ul><ul><li>END; </li></ul>
  4. 4. ELSIF Statement <ul><li>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. </li></ul>
  5. 5. Good Points! <ul><li>Use ELSIF with mutually exclusive clauses </li></ul><ul><li>Use IF…ELSIF only to test a single, simple condition. </li></ul><ul><li>Replace and simplify IF statements with Boolean expressions. </li></ul>
  6. 6. Q&A <ul><li>Use IF wisely? </li></ul><ul><li>Next Week Case. </li></ul><ul><li>Thank You! </li></ul>

×