Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 RECORD type?

share|improve this question

While RETURN NEXT is valid plpgsql syntax, RETURN RECORD 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:


For RETURNS SETOF int you can use:


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:


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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.