Condition statements
Skočit na navigaci
Skočit na vyhledávání
IF Statement
Provide conditional execution based on the truth value of a condition.
Syntax
IF boolean expression THEN sql/psm statements list [ELSEIF boolean expression THEN sql/psm statements list [ELSEIF ...]] [ELSE sql/psm statements list] END IF
CASE Statement
Provide conditional execution based on truth of search conditions or on equality of operands. This statement is similar to SQL CASE statement with differences:
- after keyword THEN is SQL/PSM statement (not value),
- CASE statement is finished with pair of keywords - END CASE,
- if all conditions are false and the CASE statement is missing the ELSE part then exception '20000' is raised.
PL/pgPSM support comma-separated predicates in simple CASE statement.
Syntax
-- simply CASE CASE expression WHEN comma separated list of values THEN sql/psm statements list [ WHEN comma separated list of values THEN sql/psm statements list [...]] END CASE -- searching CASE CASE WHEN boolean expression THEN sql/psm statements list [ WHEN boolean expression THEN sql/psm statements list [...]] END CASE