- publishing free software manuals
PostgreSQL Reference Manual - Volume 2 - Programming Guide
by The PostgreSQL Global Development Group
Paperback (6"x9"), 408 pages
ISBN 0954612035
RRP £19.95 ($34.95)

Sales of this book support the PostgreSQL project! Get a printed copy>>>

9.1.2 Supported Argument and Result Data Types

Functions written in PL/pgSQL can accept as arguments any scalar or array data type supported by the server, and they can return a result of any of these types. They can also accept or return any composite type (row type) specified by name. It is also possible to declare a PL/pgSQL function as returning record, which means that the result is a row type whose columns are determined by specification in the calling query, as discussed in Volume 1: Table Functions.

PL/pgSQL functions may also be declared to accept and return the polymorphic types anyelement and anyarray. The actual data types handled by a polymorphic function can vary from call to call, as discussed in section 5.2.5 Polymorphic Types. An example is shown in section 9.4.1 Aliases for Function Parameters.

PL/pgSQL functions can also be declared to return a “set”, or table, of any data type they can return a single instance of. Such a function generates its output by executing RETURN NEXT for each desired element of the result set.

Finally, a PL/pgSQL function may be declared to return void if it has no useful return value.

PL/pgSQL functions can also be declared with output parameters in place of an explicit specification of the return type. This does not add any fundamental capability to the language, but it is often convenient, especially for returning multiple values.

Specific examples appear in section 9.4.1 Aliases for Function Parameters and section 9.7.1 Returning From a Function.

ISBN 0954612035PostgreSQL Reference Manual - Volume 2 - Programming GuideSee the print edition