Oracle 5.0 Reference Manual page 1162

Table of Contents

Advertisement

As with other flow-control constructs,
constructs, including other
by a semicolon. You can use indentation to make nested flow-control blocks more easily readable by
humans (although this is not required by MySQL), as shown here:
DELIMITER //
CREATE FUNCTION VerboseCompare (n INT, m INT)
RETURNS VARCHAR(50)
BEGIN
DECLARE s VARCHAR(50);
IF n = m THEN SET s = 'equals';
ELSE
IF n > m THEN SET s = 'greater';
ELSE SET s = 'less';
END IF;
SET s = CONCAT('is ', s, ' than');
END IF;
SET s = CONCAT(n, ' ', s, ' ', m, '.');
RETURN s;
END //
DELIMITER ;
In this example, the inner
13.6.5.3.
ITERATE
ITERATE
label
can appear only within LOOP, REPEAT, and
ITERATE
loop again."
For an example, see
13.6.5.4.
Syntax
LEAVE
LEAVE
label
This statement is used to exit the flow control construct that has the given label. If the label is for the
outermost stored program block,
can be used within
LEAVE
For an example, see
13.6.5.5.
Syntax
LOOP
[begin_label:] LOOP
statement_list
END LOOP [end_label]
implements a simple loop construct, enabling repeated execution of the statement list, which
LOOP
consists of one or more statements, each terminated by a semicolon (;) statement delimiter. The
statements within the loop are repeated until the loop is terminated. Usually, this is accomplished with a
statement. Within a stored function,
LEAVE
Neglecting to include a loop-termination statement results in an infinite loop.
A
statement can be labeled. For the rules regarding label use, see
LOOP
Label
Syntax".
Flow Control Statements
statements. Each
IF
is evaluated only if
IF
Syntax
Section 13.6.5.5,
LEAVE
BEGIN ... END
Section 13.6.5.5,
blocks may be nested within other flow-control
IF ... END IF
must be terminated by its own
IF
is not equal to m.
n
WHILE
"LOOP
Syntax".
exits the program.
or loop constructs (LOOP, REPEAT, WHILE).
"LOOP
Syntax".
can also be used, which exits the function entirely.
RETURN
1142
END IF
statements.
ITERATE
Section 13.6.2, "Statement
followed
means "start the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents