PL/SQL - Conditions
In this chapter, we will discuss conditions in PL/SQL. Decision-making structures
require that the programmer specify one or more conditions to be evaluated or
tested by the program, along with a statement or statements to be executed if the
condition is determined to be true, and optionally, other statements to be executed if
the condition is determined to be false.
Following is the general form of a typical conditional (i.e., decision making) structure
found in most of the programming languages −
PL/SQL programming language provides following types of decision-making
statements. Click the following links to check their detail.
S.No Statement & Description
IF - THEN statement
1 The IF statement associates a condition with a sequence of statements enclosed by the
keywords THEN and END IF. If the condition is true, the statements get executed and if
the condition is false or NULL then the IF statement does nothing.
IF-THEN-ELSE statement
IF statement adds the keyword ELSE followed by an alternative sequence of statement.
2
If the condition is false or NULL, then only the alternative sequence of statements get
executed. It ensures that either of the sequence of statements is executed.
3 IF-THEN-ELSIF statement
In this chapter, we will discuss conditions in PL/SQL. Decision-making structures
require that the programmer specify one or more conditions to be evaluated or
tested by the program, along with a statement or statements to be executed if the
condition is determined to be true, and optionally, other statements to be executed if
the condition is determined to be false.
Following is the general form of a typical conditional (i.e., decision making) structure
found in most of the programming languages −
PL/SQL programming language provides following types of decision-making
statements. Click the following links to check their detail.
S.No Statement & Description
IF - THEN statement
1 The IF statement associates a condition with a sequence of statements enclosed by the
keywords THEN and END IF. If the condition is true, the statements get executed and if
the condition is false or NULL then the IF statement does nothing.
IF-THEN-ELSE statement
IF statement adds the keyword ELSE followed by an alternative sequence of statement.
2
If the condition is false or NULL, then only the alternative sequence of statements get
executed. It ensures that either of the sequence of statements is executed.
3 IF-THEN-ELSIF statement