IF
Syntax
If a Boolean expression is TRUE, the IF statement executes a series of statements, otherwise it skips the statements. There can also be an optional ELSIF clause which is a short way of writing ELSE…IF. For nested IF…ELSIF statements, only the first set of statements for which the Boolean expression evaluates to TRUE are executed, all other statements are skipped. That is, execution resumes following the final "END IF". If none of the Boolean expressions evaluate to TRUE, there can be an optional ELSE clause at the end whose statements are executed.IF boolean-expression
THEN
statements
[ELSIF boolean-expression THEN statements [elsif-clauses]]
[ELSE statements]
END IF;
elsif-clauses :=
ELSIF boolean-expression THEN statements [elsif-clauses]
boolean-expression
- Is a Boolean expression. For more information, see Boolean expression.
statements
-
Is a series of one or more PL/MX statements.
Examples
An IF statement with no other clauses:
IF finished THEN
DBMS_OUTPUT.PUT_LINE( ‘Done!’ );
END IF;
An IF statement with ELSIF and ELSE clauses:
IF finished THEN
DBMS_OUTPUT.PUT_LINE( ‘Done!’ );
ELSIF more_work_to_do THEN
DBMS_OUTPUT.PUT_LINE( ‘More work still to do!’ );
ELSE
DBMS_OUTPUT.PUT_LINE( ‘Totally Finshed!’ );
END IF;