IF Statements
The IF statement allows you to design conditional logic into your programs, and comes in three flavors, as shown in Table 1-4.
|
IF type |
Characteristics |
|
IF |
This is the simplest form of the IF statement. The condition between IF and THEN determines whether the set of statements between THEN and END IF should be executed. If the condition evaluates to FALSE, the code is not executed. |
|
IF |
This combination implements an either/or logic: based on the condition between the IF and THEN keywords, execute the code either between THEN and ELSE or between ELSE and END IF. One of these two sections of executable statements is performed. |
|
IF ELSE END IF; |
This last and most complex form of the IF statement selects an action from a series of mutually exclusive conditions and then executes the set of statements associated with that condition. If you’re writing IF statements like this using any release from Oracle9i Database Release 1 onwards, you should consider using searched CASE statements instead. |