As already stated previously in this chapter, PostgreSQL gives you the power to write stored procedures in various languages. The following options are available and shipped along with the PostgreSQL core:
- SQL
- PL/pgSQL
- PL/Perl and PL/PerlU
- PL/Python
- PL/Tcl and PL/TclU
SQL is the obvious choice to write stored procedures, and it should be used whenever possible as it gives the most freedom to the optimizer. However, if you want to write slightly more complex code, PL/pgSQL might be the language of your choice. It offers flow control and a lot more. In this chapter, some of the more advanced and less known features of PL/pgSQL will be shown (this chapter is not meant to be a complete tutorial on PL/pgSQL).
Then, the core contains code to run stored procedures in Perl. Basically, the logic is the same here. Code will be passed as...