What is the difference between
RETURN NEXT and
RETURN RECORD in PL/pgSQL? I find the manual quite confusing in explaining what
RETURN RECORD actually does. What is a
RETURN NEXT is valid plpgsql syntax,
is non-existent as such. It corresponds to how you declare the return type in the function header. Read the manual about how to return from a function.
In a function declaring
RETURNS int you can:
RETURNS SETOF int you can:
RETURN NEXT 1;
If you declare
OUT parameters, you can just:
RETURN; -- or do nothing: OUT params are returned at the end of the function anyway
Or if you combine
OUT parameters with
RETURNS SETOF record - effectively the same as
RETURNS TABLE (...):
The current state of all
OUT parameters is returned as next row.
Finally, to return a whole set of rows at once:
RETURN QUERY ...
record is a special data type. It's meaning depends on where you use it. Like I posted in my answer to your previous question: