| The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming Guide
by The PostgreSQL Global Development Group Paperback (6"x9"), 478 pages ISBN 9781906966065 RRP £14.95 ($19.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
9.6.1.1 RETURN
RETURN expression;
RETURN with an expression terminates the
function and returns the value of
expression to the caller. This form
is used for PL/pgSQL functions that do
not return a set.
When returning a scalar type, any expression can be used. The expression's result will be automatically cast into the function's return type as described for assignments. To return a composite (row) value, you must write a record or row variable as the expression.
If you declared the function with output parameters, write just
RETURN with no expression. The current values
of the output parameter variables will be returned.
If you declared the function to return void, a
RETURN statement can be used to exit the function
early; but do not write an expression following
RETURN.
The return value of a function cannot be left undefined. If
control reaches the end of the top-level block of the function
without hitting a RETURN statement, a run-time
error will occur. This restriction does not apply to functions
with output parameters and functions returning void,
however. In those cases a RETURN statement is
automatically executed if the top-level block finishes.
| ISBN 9781906966065 | The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming Guide | See the print edition |