PL/pgSQL functions must return a value that matches the data type specified as their return type in the
CREATE FUNCTION command that created them. Values are returned with a
RETURN statement. A RETURN statement is typically
located at the end of a function, but will also often be located within an IF statement or
other statement that directs the flow of the function. If a function's RETURN statement
is located within one of these control statements, you should still include a return statement at the end of the function
(even if the function is designed to never reach that last RETURN statement). The syntax
of a RETURN statement is shown in Example 11-26.
Example 11-26. Syntax of the RETURN statement
' LANGUAGE 'plpgsql';
For a demonstration of the RETURN statement, examine any PL/pgSQL function example
within this chapter.