postgresql_16:6.6.1.2 Supported Argument and Result Data Types
PostgreSQL 16 > Server Programming > PL/pgSQL — SQL Procedural Language > Overview > 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 accepting record, which means that any composite type will do as input, or 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 (see postgresql_16:3.4.2.1).
PL/pgSQL functions can be declared to accept a variable number of arguments by using the VARIADIC marker. This works exactly the same way as for SQL functions, as discussed in (see postgresql_16:6.1.5.6).
PL/pgSQL functions can also be declared to accept and return the polymorphic types described in (see postgresql_16:6.1.2.5), thus allowing the actual data types handled by the function to vary from call to call. Examples appear in (see postgresql_16:6.6.3.1).
PL/pgSQL functions can also be declared to return a “set” (or table) of any data type that can be returned as a single instance. Such a function generates its output by executing RETURN NEXT for each desired element of the result set, or by using RETURN QUERY to output the result of evaluating a query.
Finally, a PL/pgSQL function can be declared to return void if it has no useful return value. (Alternatively, it could be written as a procedure in that case.)
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. The RETURNS TABLE notation can also be used in place of RETURNS SETOF.
Specific examples appear in (see postgresql_16:6.6.3.1) and (see postgresql_16:6.6.6.1).