Lab 5.3 Nested IF Statements
Lab ObjectivesAfter this Lab, you will be able to: |
You have encountered different types of conditional controls: IF-THEN statement, IF-THEN-ELSE statement, and ELSIF statement. These types of conditional controls can be nested inside of another—for example, an IF statement can be nested inside an ELSIF and vice versa. Consider the following:
▪ FOR EXAMPLE
DECLARE v_num1 NUMBER := &sv_num1; v_num2 NUMBER := &sv_num2; v_total NUMBER; BEGIN IF v_num1 > v_num2 THEN DBMS_OUTPUT.PUT_LINE ('IF part of the outer IF'); v_total := v_num1 - v_num2; ELSE DBMS_OUTPUT.PUT_LINE ('ELSE part of the outer IF'); v_total := v_num1 + v_num2; IF v_total < 0 THEN DBMS_OUTPUT.PUT_LINE ('Inner IF'); v_total ...
Get Oracle® PL/SQL® Interactive Workbook, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.