This topic describes the flow control functions that are supported by PolarDB-X.

The following table describes the flow control functions that are supported by PolarDB-X.

Function Description
CASE expression WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... WHEN conditionN THEN resultN ELSE resultEND In the syntax, CASE indicates that the function starts to evaluate whether condition1 is true. END indicates that the function terminates the evaluation. If condition1 is true, result1 is returned. If condition2 is true, result2 is returned. If no conditions are true, result is returned. The CASE expression returns the result of the first condition that evaluates to true and terminates the evaluation of the subsequent conditions in WHEN clauses.
IF(expr,v1,v2) If expr is true, v1 is returned. If expr is not true, v2 is returned.
IFNULL(v1,v2) If v1 is not NULL, v1 is returned. If v1 is NULL, v2 is returned.
NULLIF(expr1, expr) Returns NULL if expr1 = expr2 is true. Otherwise, the function returns expr1.