Database Reference
In-Depth Information
Note: Avoid using GOTO statements. Purist modular programming does
not allow use of GOTO statements. It is always possible to construct a
piece of code properly without using GOTO statements. GOTO state-
ments lead to spaghetti code.
24.7.1
Selection
The IF and the CASE statements allow you to execute different code
depending on the value of some expression. The expression must be a Bool-
ean expression. That is, the expression must always evaluate to true, false, or
NULL, where NULL is equivalent to false.
24.7.1.1
The IF Statement
Each branch of an IF statement will be executed based on a condition. The
situation where all conditions fail is covered by the default ELSE clause.
Every condition can be a different Boolean expression. The syntax of the IF
statement is shown in Figure 24.13.
Now let's use an IF statement to display total dollars due based on due
dates for outstanding amounts of money. In this example, we define a date
called TODAY. The IF statement causes an addition to a total based on the
due date of each row. See the result in Figure 24.14.
Figure 24.13
IF Statement
Syntax.
SET SERVEROUTPUT ON
DECLARE
TODAY DATE DEFAULT '01-JUL-2001';
Search WWH ::




Custom Search