Why PL/pgSQL?
PL/pgSQL is a powerful SQL scripting language heavily influenced by PL/SQL, the stored procedure language distributed with Oracle. It is included in the vast majority of PostgreSQL installations as a standard part of the product, so it usually requires no setup at all to begin.
PL/pgSQL also has a dirty little secret. The PostgreSQL developers don't want you to know that it is a full-fledged SQL development language, capable of doing pretty much anything within the PostgreSQL database.
Why is that a secret? For years, PostgreSQL did not claim to have stored procedures. PL/pgSQL functions were originally designed to return scalar values and were intended for simple mathematical tasks and trivial string manipulation.
Over the years, PL/pgSQL grew a rich set of control structures and gained the ability to be used by triggers, operators, and indexes. In the end, the developers were grudgingly forced to admit that they had a complete stored procedure development system on their hands...