|
IF statements provide conditional execution based on the value of a condition. The IF . . . THEN . . . [ELSE . . .] construct controls flow based on which of two statement blocks will be executed.
You may use IF statements in the body of both stored procedures and triggers.
There is no limit to the number of nested IF statements allowed, although the query remains subject to the usual total length limitation and other applicable limitations.
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.
|
Chapter contents
Prev topic: HAVING
|