Oracle pl/sql control statments

taybabashir1 2,039 views 11 slides Jul 10, 2013
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

its the if, else if. nested statements.


Slide Content

Oracle
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
•IF THEN...END IFstatement is a single-level
 
conditional statement which executes a sequence of
statements based on a given condition. 
•Syntax:
IF condition THEN
executable statements
END IF;
•Condition
Expression evaluates to TRUE or FALSE
If TRUE commands execute

Demonstration

5
PL/SQL Comparison Operators

IF THEN ELSE statement
•The
 
IF-THEN-ELSEstatement is next level of extension
 
of above the
 
IF-THENstatement, 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 ENDIFstatement
 
 
• For multiple possible outcomes of a
 
condition, we
use the
 
IF THEN ELSIF ENDIFstatement
   
•Syntax:

 
IF condition1 THEN
sequence_of_statements1
ELSIF condition2 THEN
sequence_of_statements2
ELSE
sequence_of_statements3
END IF;

Demonstration

Nested IF statement
•When using an ELSIF construct, it is not necessary
to specify what action should be taken if none of
the conditions evaluate to TRUE. In other words, an
ELSE clause is not required in the ELSIF construct.