NOT TRUE FALSE NULL OR TRUE FALSE NULL TRUE FALSE NULL FALSE TRUE NULL AND TRUE

Not true false null or true false null true false

This preview shows page 134 - 138 out of 302 pages.

NOT TRUE FALSE NULL OR TRUE FALSE NULL TRUE FALSE NULL FALSE TRUE NULL AND TRUE FALSE NULL TRUE FALSE NULL TRUE NULL NULL NULL FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE FALSE NULL NULL NULL Boolean Conditions with Logical Operators You can build a simple Boolean condition by combining number, character, or date expressions with comparison operators. You can build a complex Boolean condition by combining simple Boolean conditions with the logical operators AND , OR , and NOT . In the logic tables shown in the slide: • FALSE takes precedence in an AND condition and TRUE takes precedence in an OR condition. • AND returns TRUE only if both of its operands are TRUE . • OR returns FALSE only if both of its operands are FALSE . • NULLANDTRUE always evaluate to NULL because it is not known whether the second operand evaluates to TRUE or not. Note: The negation of NULL ( NOT NULL ) results in a null value because null values are indeterminate.
Image of page 134
Oracle9 i : PL/SQL Fundamentals 4 - 17 Copyright © Oracle Corporation, 2001. All rights reserved. 4-17 Boolean Conditions What is the value of V_FLAG in each case? V_REORDER_FLAG V_AVAILABLE_FLAG V_FLAG TRUE TRUE TRUE FALSE NULL TRUE NULL FALSE v_flag := v_reorder_flag AND v_available_flag; ? ? ? ? Building Logical Conditions The AND logic table can help you evaluate the possibilities for the Boolean condition on the slide. Answers 1. TRUE 2. FALSE 3. NULL 4. FALSE
Image of page 135
Oracle9 i : PL/SQL Fundamentals 4 - 18 Copyright © Oracle Corporation, 2001. All rights reserved. 4-18 Iterative Control: LOOP Statements Loops repeat a statement or sequence of statements multiple times. There are three loop types: Basic loop FOR loop WHILE loop Iterative Control: LOOP Statements PL/SQL provides a number of facilities to structure loops to repeat a statement or sequence of statements multiple times. Looping constructs are the second type of control structure. PL/SQL provides the following types of loops: Basic loop that perform repetitive actions without overall conditions • FOR loops that perform iterative control of actions based on a count • WHILE loops that perform iterative control of actions based on a condition Use the EXIT statement to terminate loops. For more information, refer to PL/SQL User’s Guide and Reference, “Control Structures.” Note: Another type of FOR LOOP , cursor FOR LOOP , is discussed in a subsequent lesson.
Image of page 136
Oracle9 i : PL/SQL Fundamentals 4 - 19 Copyright © Oracle Corporation, 2001. All rights reserved. 4-19 Basic Loops Syntax: LOOP statement1 ; . . . EXIT [WHEN condition ]; END LOOP; condition is a Boolean variable or expression (TRUE, FALSE, or NULL); -- delimiter -- statements -- EXIT statement -- delimiter Basic Loops The simplest form of LOOP statement is the basic (or infinite) loop, which encloses a sequence of statements between the keywords LOOP and END LOOP . Each time the flow of execution reaches the END LOOP statement, control is returned to the corresponding LOOP statement above it. A basic loop allows execution of its statement at least once, even if the condition is already met upon entering the loop. Without the
Image of page 137
Image of page 138

You've reached the end of your free preview.

Want to read all 302 pages?

  • Fall '17
  • Alex

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture