Function argument list

A function declares its argument list by specifying at least one argument type in a comma-separated list wrapped in parentheses following the function name. Each parameter has the following:

  • A mandatory SQL type (or a user-defined type)
  • An optional name
  • An optional default value, which is used when the function is invoked without a value for the parameter
  • An optional direction, which is used when the parameter could also be a return value

If the function does not require any arguments, the list will be empty, resulting in a couple of empty parentheses. If no name is specified for an argument, it will be available through the positional aliases $1, $2, and so on. As a simple example, consider Listing 1, where three ...

Get PostgreSQL 11 Server Side Programming Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.