CASE Statement


or

CASE
 WHEN search_condition THEN statement
 [WHEN search_condition THEN statement ...]
 [ELSE statement]
END CASE

CASE implements a complex conditional construct. If a search_condition evaluates to true, the corresponding SQL statement is executed. If no search condition matches, the statement in the ELSE clause is executed.

Please note that the syntax of a CASE statement inside a stored procedure differs slightly from that of the SQL CASE expression. The CASE statement can not have an ELSE NULL clause, and the construct is terminated with END CASE instead of END. Leia "Funções de Fluxo de Controle".

Retornar