Team Fly 

Page 225

So, not only must the date be greater than April 11th, 1963, but your last name must be equal to 'PAKMAN' in order to get the raise. This is a method we use to make sure that human resource programs ensure that programmers get a raise every year.

What you should also notice in this code is that there are now two END IF statements. This is a required construct, since you must always pair up an IF statement with an END.IF. So, if you are going to have nested IF statements, you must ensure that each is paired with a matching END IF.

NOTE
Each IF statement is followed by its own THEN. There is also no semicolon (;) terminator on a line that begins with an IF. The END IF; clause will always terminate your IF statements and include a semicolon (;).

NOTE
Each IF statement block must have at least one line of program code. If you wish to do nothing within your program code, then simply use the NULL; command.

IF/THEN/ELSE The IF/THEN/ELSE construct is similar to the simple IF/THEN construct. The difference here is that if the condition executes as FALSE, you perform the program statements that follow the ELSE statement. The following code illustrates this logic within PL/SQL:

IF l_date > '11-APR-63' then
            l_salary :=  l_salary * 1.15; -- Increase salary by 15%
ELSE
l_salary := l_salary * 1.05;  -- Increase salary by 5%
END IF;

In this code listing, you see the condition that if the date is greater than April 11, 1963, you will get a 15 percent salary increase. However, when the date is less than or equal to this date, you only receive a 5 percent increase.

Team Fly 
0244