Conditional Control Statments
Conditional evaluation refers to the ability to process a portion of code depending on whether certain criteria are met. We use conditional evaluation for activities every day.Using this type of logic in PL/SQL gives the programmer control over what code gets run and under what conditions it is run.
There are two conditional control statements in PL/SQL
IF-THEN-ELSE
The most basic conditional evaluation is an IF-THEN statement. IF a condition is
met, THEN do something. Implicit with this logic is IF a condition is not met, skip
the code that follows and continue with the rest of the program.
The syntax for an IF-THEN statement is
IF condition
THEN
action;
END IF;
Read more about IF-THEN-ELSE statement
CASE
CASE statement provides a different approach to conditional evaluation.
It simplifies the syntax a bit by requiring the condition to be passed only one time.
The syntax is
CASE expression
WHEN test1 THEN action;
WHEN test2 THEN action;
…
END CASE;
Read more about CASEĀ statement