Database Reference
In-Depth Information
The Procedural Language
In the previous chapter, you saw what wonders you can do with SQL, but there is
still some more magic left to show you, so let's investigate SQL further.
Before we begin, let's irst consider and compare what you would choose to do:
• Execute individual SQL statements again and again, which involves
numerous server round trips, or even worse if it's over long-distance
networks
• Execute blocks of code that are stored in the DBMS, which serve the same
purpose without involving those server round trips
The second option seems to be an obvious choice. Luckily, this block of code is
actually a procedural language. In the case of PostgreSQL, this procedural language
is named Procedural Language/PostgreSQL ( PL/pgSQL ).
PL/pgSQL is to PostgreSQL what PL/SQL is to Oracle (or what Transact/SQL is
to Microsoft SQL Server). Procedural languages can be used to write functions,
and in PL/pgSQL, function is a labeled sequence of statements written inside an
SQL expression. By doing so, you are actually extending the server. These server
extensions are also known as stored procedures . This is why we're going to learn
about this now.
Based upon this, here is what you will learn in this chapter:
• What is a procedural language?
• PL/pgSQL language, conceptual elements, declarations, writing functions,
control structures, and exception handling
• Interfacing through other procedural languages, namely PL/Python, PL/Tcl,
and PL/Perl
Search WWH ::




Custom Search