IF statements provide conditional execution based on the value of a condition. The
IF . . . THEN . . . ELSE . . . END IF construct controls flow based on which of two statement blocks will be executed. You may also use the
IF . . . ELSE syntax.
You may use IF statements in the body of both stored procedures and triggers.
The following example uses the IF statement to set the variable Negative to either 1 or 0, depending on whether the value of vInteger is positive or negative.
The following example uses the IF statement to test the loop for a defined condition (SQLSTATE = '02000'). If it meets this condition, then the
WHILE loop is terminated.