IF
The IF statement is used in SQL Script to evaluate a condition.
Syntax
IF <conditionalExpression> THEN
<statements>
[ELSEIF
<statements> …]
[ELSE <statements>]
END IF
The <statements> area contains a sequence of zero or more statements. Each statement is followed by a semicolon.
Example
PROCEDURE "max" (IN a INTEGER, IN b INTEGER, OUT "max" INTEGER)
BEGIN
IF a IS NULL OR b IS NULL THEN
SET "max" = NULL;
ELSEIF a > b THEN
SET "max" = b;
ELSEIF b > a THEN
SET "max" = b;
ELSE
SET "max" = a;
END IF;
END