Saturday, February 25, 2012

PL/SQL IF ELSE statement / Conditional statements



Conditional Statements in PL/SQL

The PL/SQL IF statement allows you to execute a sequence of statements conditionally. The IF statements evaluate a condition. The condition can be anything that evaluates to a logical true or false such as comparison expression or combination of multiple comparison expressions. The programming constructs are similar to how you use in programming languages like Java and C++.


IF THEN ELSE STATEMENT

Type 1)

IF condition
THEN
statement 1;
ELSE
statement 2;
END IF;


Type 2)

IF condition 1
THEN
statement 1;
statement 2;
ELSIF condtion2 THEN
statement 3;
ELSE
statement 4;
END IF


Type 3)

IF condition 1
THEN
statement 1;
statement 2;
ELSIF condtion2 THEN
statement 3;
ELSE
statement 4;
END IF;


Type 4)

IF condition1 THEN
ELSE
IF condition2 THEN
statement1;
END IF;
ELSIF condition3 THEN
statement2;
END IF;

No comments:

Post a Comment