Control statements

There are a number of control statements for logical flow and decision making in the body of the procedure 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, ... )

For complete descriptions of each, see the entries in Chapter 6, “SQL Statements,” in the Sybase IQ Reference Manual.