|PostgreSQL Reference Manual - Volume 2 - Programming Guide|
by The PostgreSQL Global Development Group
Paperback (6"x9"), 408 pages
RRP £19.95 ($34.95)
Sales of this book support the PostgreSQL project! Get a printed copy>>>
5.3 User-Defined Functions
PostgreSQL provides four kinds of functions:
- query language functions (functions written in SQL) (section 5.4 Query Language (SQL) Functions)
- procedural language functions (functions written in, for example, PL/pgSQL or PL/Tcl) (section 5.7 Procedural Language Functions)
- internal functions (section 5.8 Internal Functions)
- C-language functions (section 5.9 C-Language Functions)
Every kind of function can take base types, composite types, or combinations of these as arguments (parameters). In addition, every kind of function can return a base type or a composite type. Functions may also be defined to return sets of base or composite values.
Many kinds of functions can take or return certain pseudo-types (such as polymorphic types), but the available facilities vary. Consult the description of each kind of function for more details.
It's easiest to define SQL functions, so we'll start by discussing those. Most of the concepts presented for SQL functions will carry over to the other types of functions.
Throughout this chapter, it can be useful to look at the reference
page of the
CREATE FUNCTION command to
understand the examples better. Some examples from this chapter
can be found in ‘funcs.sql’ and
‘funcs.c’ in the ‘src/tutorial’
directory in the PostgreSQL source
|ISBN 0954612035||PostgreSQL Reference Manual - Volume 2 - Programming Guide||See the print edition|