Control statements

There are several control statements for logical flow and decision making in the body of a procedure, trigger, or user-defined function, or in a batch. Available control statements include:

Control statement Syntax

Compound statements

BEGIN [ ATOMIC ]
   Statement-list
END

Conditional execution: IF

IF condition THEN
   Statement-list
ELSEIF condition THEN
   Statement-list
ELSE
   Statement-list
END IF

Conditional execution: CASE

CASE expression
WHEN value THEN
   Statement-list
WHEN value THEN
   Statement-list
ELSE
   Statement-list
END CASE

Repetition: WHILE, LOOP

WHILE condition LOOP
   Statement-list
END LOOP

Repetition: FOR cursor loop

FOR loop-name
   AS cursor-name CURSOR FOR
   select-statement
DO
   Statement-list
END FOR

Break: LEAVE

LEAVE label

CALL

CALL procname( arg, ... )
 See also

Compound statements
Declarations in compound statements
Atomic compound statements