PL/pgSQLでは、無名ブロックの DO 文を除けば、すべてのコードが関数・プロシージャ定義の中に含まれる必要があります。また、代入演算子は同じく := ですが、文字列連結に `||` ではなく format () 関数や `%` プレースホルダを使うことが推奨されます。
Here are only a few functions to demonstrate how easy it is to write PL/pgSQL functions. For more complex examples the programmer might look at the regression test for PL/pgSQL.