The ELSE clause executes if no true previous condition exists in the IF clause or any of the ELIF clauses.
In the following example, the SPL function uses an IF statement with both an ELIF clause and an ELSE clause. The IF statement compares two strings.
The function displays 1 to indicate that the first string comes before the second string alphabetically, or -1 if the first string comes after the second string alphabetically. If the strings are the same, a zero (0) is returned.
CREATE FUNCTION str_compare (str1 CHAR(20), str2 CHAR(20))
RETURNING INT;
DEFINE result INT;
IF str1 > str2 THEN
LET result =1;
ELIF str2 > str1 THEN
LET result = -1;
ELSE
LET result = 0;
END IF
RETURN result;
END FUNCTION -- str_compare
Enterprise Edition Home |
Express Edition Home |
[ Top of Page | Previous Page | Next Page | Contents |
Index ]