Provides conditional execution based on the truth value of a conditional expression.
IFstatement allows a sequence of
procedural-sql-statementsto be conditionally executed depending on the truth value of a
For a list of
procedural-sql-statements, see Procedural SQL Statements.
All of the predicates supported by Mimer SQL may be used in the
search-condition, see Predicates.
In a basic
IFstatement, the sequence of
THENclause will be executed if
search-conditionevaluates to true, otherwise the sequence of
ELSEclause will be executed.
One or more
IFstatements can be nested by using the
ELSEIFclause in place of an
ELSEclause containing another
search-condition, see Search Conditions.
search-conditionequals null or directly includes the null value, it evaluates to unknown and its treated as false. If it is required that the conditional expression test for the null value, then the correct behavior is achieved by using the
IS NULLpredicate, see The NULL Predicate.
Exampleif X > 50 then SET X = 50; SET Y = 1; else SET Y = 0; end if; declare bookExists boolean; set bookExists = exists (select * from books where ... ); if bookExists then ... end if; declare bookTitle row(ISBN varchar(20), Title varchar(50)); ... if booktitle = ('0-201-43328-1','JDBC API Tutorial and Reference') then ... end if;
For more information, see the Mimer SQL Programmer's Manual, Conditional Execution Using IF.
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40