4.1 IF Statement
IF statement two forms; If-then if-then-else using If-then, you can specify a set of actions that need to be performed. If-then-else statement specifies two sets of actions
1. If-then true to execute a statement sequence
Structure:
IF CONDITION Then
STATEMENT 1;
.......
STATEMENT N;
END IF;
2. If-then-else statements
If-then specifies that a sequence of statements is required when the current condition evaluates to True. When the condition evaluates to False, no special activity is taken, just to continue the execution of the program, using the If-then-else statement to specify two sets of statements. The condition evaluates to true, executing a set when the condition is false and another set of
Structure:
IF CONDITION Then
STATEMENT 1;
ELSE
STATEMENT 2;
END IF;
STATEMENT 3;
3. Null condition: In some cases, the only condition evaluated in the IF statement may be NULL instead of true or false. For the if-then structure, the specified statement is not executed if the related condition evaluates to NULL. Executes the first executable statement after the end if, for the If-then-else statement, the statement formulated by the reserved word else is executed when the related condition evaluates to NULL.
4. ElseIf statements
ElseIf structure
IF Conditiono 1 Then
STATEMENT 1;
ELSEIF CONDITION 2 Then
STATEMENT2;
ELSEIF CONDITION 3THEN
STATEMENT3;
....
ELSE
STATEMENT N;
END IF;
The reserved word if identifies the ElseIf structure to begin with. Condidtion 1 to Condidtion N is a series of conditions in which the structure evaluates to TRUE or false, and these conditions are mutually exclusive. In other words, if Condidtion 1 evaluates to TRUE, statement 1 is executed, and the execution control goes to the first executable statement after the reserved word end If. The rest of the ElseIf structure is ignored. When the result of Condidtion 1 is false, the execution goes back to the ElseIf section. ElseIf statements can contain any number of elseif clauses
4.3 Nested IF statements
ORACLE PL/SQL Instance refinement fourth conditional control: if statement