Compound PL/pgSQL executable statements [YSQL]

Compound PL/pgSQL executable statements

The following table lists all of the compound PL/pgSQL executable statements.

  • The Statement Name column links to the page where the semantics are described.
  • The Syntax rule name column links to the definition on the omnibus Grammar Diagrams reference page.
STATEMENT NAME SYNTAX RULE NAME COMMENT
block statement plpgsql_block_stmt declare <declarations>
begin <executable statements>
exception <handlers>
end;
case statement plpgsql_case_stmt Simple form:
case <expression>
when <value> then <executable statements> ...
else <executable statements>
end case;

Searched form:
case
when <boolean expression> then <executable statements> ...
else <executable statements>
end case;
if statement plpgsql_if_stmt if <boolean expression> then <executable statements>
elsif <boolean expression> then <executable statements> ...
else <executable statements>
end if;
loop statement plpgsql_loop_stmt unbounded loop or bounded loop