Lesson 4 - Control Structures - Practical
Lesson 4 - Control Structures - Practical
Lesson 4 – Practical
Control Structures
Learning Objectives
IFboolean-expression THEN
statements
END IF
;
IFboolean-expression THEN
statements [ ELSIF boolean-expression THEN
statements [ ELSIF boolean-expression THEN
statements ...]]
[ ELSE statements ]
END IF;
IF number = 0 THEN
result := ''zero''; ELSIF number > 0 THEN result := ''positive'';
ELSIF number < 0 THEN result := ''negative'';
ELSE -- hmm, the only other possibility is that number IS NULL
result := ''NULL'';
END IF;
LOOP
-- some computations Loops
IF count > 0 THEN EXIT;
-- exit loop
END IF;
END LOOP; [<<label>>]
LOOP LOOP statements
-- some computations END LOOP;
EXIT WHEN count > 0;
END LOOP;
BEGIN
-- some computations IF stocks > 100000
THEN EXIT;
-- illegal. Can't use EXIT outside of a LOOP
END IF;
END;
WHILE
[<<label>>]
WHILE expression LOOP
statements
END LOOP;