Oraclepresentation 130710113309 Phpapp02
Oraclepresentation 130710113309 Phpapp02
CONTROL STRUCTURE
PL/SQL IF/THEN/ELSE Statement
The IF/THEN statement checks a Boolean value or expression
and if true, executes the statements in the THEN clause.
If the condition is false, the statements in the THEN
clause are skipped and execution jumps to the END IF, and
the expression that is checked must return a true or
false. It can be a simple Boolean variable or a compound
expression joined with AND/OR clauses, and the expression
can even be a PL/SQL function that returns a Boolean
value.
• IF...THEN
• IF...THEN...ELSE
• IF...THEN...ELSIF...ENDIF
• IF…THEN…ELSIF…THEN…ELSE…END IF
•
IF THEN statement
5
IF THEN ELSE statement
• The IF-THEN-ELSE statement is next level of extension
of above the IF-THEN statement, as it provides the
ability to give direction for FALSE or NULL also.
• Syntax:
IF condition THEN
executable statements 1
ELSE
executable statements 2
END IF;
Demonstration
IF THEN ELSIF ENDIF statement
• For multiple possible outcomes of a condition, we
use the IF THEN ELSIF ENDIF statement
• Syntax:
IF condition1 THEN
sequence_of_statements1
ELSIF condition2 THEN
sequence_of_statements2
ELSE
sequence_of_statements3
END IF;
Demonstration
Nested IF statement