Oracle Database 10g SQL (Osborne ORACLE Press Series)

You may use the IF, THEN, ELSE, ELSIF, and END IF keywords in PL/SQL for performing conditional logic. The following syntax illustrates the use of conditional logic:

IF condition1 THEN statements1 ELSIF condition2 THEN statements2 ELSE statements3 END IF;

where

This conditional logic flows as follows :

You can also embed IF statements within another IF statement, as shown in the following example:

IF count > 0 THEN message := 'count is positive'; IF area > 0 THEN message := 'count and area are positive'; END IF ELSIF count = 0 THEN message := 'count is zero'; ELSE message := 'count is negative'; END IF;

Категории