The server-side processing extends data processing capabilities of RDBMS. It is provided by the database.
A native option for the server-side processing is a view (see Section 2.1). It does not give much expressive power, however it is ANSI SQL standard compliant [7]. A view is a relation which state is generated on demand.
The view may be perceived as a rule, which is written in SQL. The primary objective of views is to allow a transparent and on demand selection and projection operations. So a relation can be created, which is generated as a projection and selection of some other relations. This is a way of embedding queries into the database system. Trying more sophisticated processing fails, usually due to the limitations of expressive power of SQL itself.
Another option is procedures or functions. They are called Persistent, Stored Modules: SQL/PSM or just PSM [7]. The idea behind it is to store some program (a procedure or function), in the database and call it from an SQL query. The function is written in some language. It takes some parameters and optionally returns a value. According to the standard (ANSI SQL) PSM are implemented using SQL and some additional, procedural extensions as loops and conditional statements. The function may return a value, which can be used as the value of an attribute in a SELECT statement or in a VALUES clause.
Some RDBMS go a little bit beyond the standard at this point[30,18]. They usually allow a PSM to be implemented using some procedural language, which gives better flexibility and expressive power than SQL. A good example is PL/SQL provided by Oracle. PostgreSQL goes even further; it supports: PL/pgSQL, PL/Tcl, PL/Perl, PL/Python which resemble PL/SQL, Tcl, Perl, and Python languages respectively [30,18]. What is more, PostgreSQL gives an ability to add any language at run-time and use it to implement functions. The value returned by the function can be a single atom, a tuple or a set of tuples which may be perceived as a relation.
Having such a variety of options a function can be used as an attribute, when it returns a single value, or as a relation, when it returns a tuple, or set of tuples. So the function can be placed in a query, as an attribute or relation, depending on the return value.
A function may issue queries and incorporate virtually any procedural processing. The processing itself is controlled by a hard-coded logic (for example a series of conditional statements) which is the body of function. Using functions is similar to the processing provided by the client applications, but in this case the application is embedded into the database.
Igor Wojnicki 2005-11-07