RETURN NEXT is valid plpgsql syntax,
is non-existent as such. Read the manual about how to return from a function. It directly corresponds to how you declared the return type in the function header.
In a function declaring
RETURNS int you can:
RETURNS SETOF int you can use:
RETURN NEXT 1;
If you declared
OUT parameters, you can just:
Or if you combine OUT parameters with
RETURNS SETOF record - which is effectively the same as
RETURNS TABLE (...):
The current state of all
OUT parameters is returned automatically in this case.
Finally, there is the short syntax to return a whole set of rows at once:
RETURN QUERY ...
record is just a special data type that has a slightly different meaning, depending on where you use it. Like I posted in my answer to your preceding question: "Declare variable of table type in PL/pgSQL", the manual explains the
record type in plpgsql here.