The Structure of PL/pgSQLAs mentioned, PL/pgSQL is a block-oriented language. A block can be defined using DECLARE , BEGIN , and END . All variables have to be declared within the DECLARE section and are initialized with NULL every time a block is entered. PostgreSQL supports database transactions (see Chapter 5, "Understanding Transactions"). Functions and triggers ( triggers are a feature used to start a certain task after a predefined event) can be embedded only in a transaction started by an external query ”they don't start separate transactions, because PostgreSQL doesn't support nested transactions. Understanding transactions is an extremely important issue; don't confuse BEGIN / END for transaction control with BEGIN / END in PL/pgSQL functions. |