Oracle 5.0 Reference Manual page 1161

Table of Contents

Advertisement

Each
statement_list
permitted.
To handle situations where no value is matched by any
BEGIN ... END
purposes of clarity only, and is not otherwise significant.)
DELIMITER |
CREATE PROCEDURE p()
BEGIN
DECLARE v INT DEFAULT 1;
CASE v
WHEN 2 THEN SELECT v;
WHEN 3 THEN SELECT 0;
ELSE
BEGIN
END;
END CASE;
END;
|
13.6.5.2.
Syntax
IF
IF
search_condition
[ELSEIF
[ELSE statement_list]
END IF
The
statement for stored programs implements a basic conditional construct.
IF
If the
search_condition
statement_list
executes.
Each
statement_list
permitted.
An
IF ... END IF
terminated with a semicolon, as shown in this example:
DELIMITER //
CREATE FUNCTION SimpleCompare(n INT, m INT)
RETURNS VARCHAR(20)
BEGIN
DECLARE s VARCHAR(20);
IF n > m THEN SET s = '>';
ELSEIF n = m THEN SET s = '=';
ELSE SET s = '<';
END IF;
SET s = CONCAT(n, ' ', s, ' ', m);
RETURN s;
END //
DELIMITER ;
Flow Control Statements
consists of one or more SQL statements; an empty
block, as shown in this example. (The indentation used here in the
THEN
statement_list
search_condition
THEN statement_list] ...
Note
There is also an
IF()
described here. See
can have THEN, ELSE, and
evaluates to true, the corresponding
executes. If no
search_condition
consists of one or more SQL statements; an empty
block, like all other flow-control blocks used within stored programs, must be
clause, use an
WHEN
[883]
function, which differs from the
Section 12.4, "Control Flow
clauses, and it is terminated with
ELSEIF
matches, the
1141
statement_list
containing an empty
ELSE
ELSE
statement
IF
Functions". The
statement
IF
or
clause
THEN
ELSEIF
clause
ELSE
statement_list
statement_list
is not
clause is for
END
IF.
is not

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents