Database Reference
In-Depth Information
a IS NULL
a IS NOT NULL
IF student_name LIKE 'Su%'
name := 'Ajit ' || 'Singh';
8.7 Conditional and Sequential Control
8.7.1 IF Statements
The IF statement allows us to design conditional logic into programs. For example take a
following case where we have to decide when one is to be executed.
 If the salary is between ten and twenty thousand, then apply a bonus of Rs1,500.  If the
salary is between twenty and forty thousand, apply a bonus of Rs1,000.  If the salary is
over forty thousand, give the employee a bonus of Rs500.
Some constructs are required in our programming language so that they can respond to all
sorts of situations and requirements, including conditional behavior, such as: “if a is true,
then do b, otherwise do c.”
PL/SQL supports conditional logic with the IF statement:
IF condition THEN Statement 1;
……………
…..........….
Statement N;
END IF;
When an IF-THEN statement is executed, a condition is evaluated to either TRUE or
FALSE. If the value of condition is TRUE, control is transferred to the first executable
statement of the IF-THEN construct. If the value of condition is to FALSE, control is
passed to the first executable statement after the END IF statement.
Example 3:
DECLARE
num1 NUMBER := 15;
num2 NUMBER := 10;
temp NUMBER;
BEGIN
IF num1 > num2 THEN
Search WWH ::




Custom Search