ALLBASE/SQL Reference Manual (36216-90216)

442 Chapter11
SQL Statements E - R
IF
IF
The IF statement is used to allow conditional execution of one or more statements within a
procedure.
Scope
Procedures only
SQL Syntax
IF
Condition
THEN [
Statement
;[...]]
[ELSEIF
Condition
THEN [
Statement
; [...]]]
[ELSE [
Statement
; [...]]] ENDIF;
Parameters
Condition
specifies anything that is allowed in a search condition except subqueries,
column references, host variables, dynamic parameters, aggregate
functions, string functions, date/time functions involving column
references, long column functions, or TID functions. Local variables,
built-in variables, and parameters may be included. See Chapter 9 ,
“Search Conditions,” for more information.
Statement
is any statement allowed in a procedure, including a compound statement.
The statement may also be empty.
Description
IF statements can be nested. In a nested IF statement, each ELSE is associated with
the closest preceding IF.
Local variables, and parameters can be used anywhere a host variable would be
allowed.
Each
Statement
may be a single simple statement, a compound statement, or empty.
Authorization
Anyone can use the IF statement.