0

I have a function that loop a table and do processing returning values. I was returning SETOF VARCHAR[] and returning with RETURN NEXT the_varchar_array and worked fine.

But now I need to return some INTEGER before the VARCHAR[].

How I can define the returning value to return the INTEGER value and the VARCHAR[] and how I returning they inside the function?

If a define as RETURNS SETOF INTEGER, INTEGER, INTERGER, VARCHAR[], it don't works.

If I use RETURNS TABLE(a INTEGER, b INTEGER, c INTEGER, d VARCHAR[]), works, but I don't know how to return each value inside the function.

RETURN NEXT a,b,c,d doesn't works. Only RETURN NEXT return an empty line.

3
  • This development documentation at PostgreSQL shows the different ways to return values from functions. You might have to look into a composite return type or a row of data containing all of your values. Commented Dec 1, 2011 at 17:26
  • @Cory I used a composite type and solved my problem. Please, answer this question to select your answer. Commented Dec 1, 2011 at 18:04
  • I converted my comment to an answer. Commented Dec 1, 2011 at 19:28

2 Answers 2

2

This development documentation at PostgreSQL shows the different ways to return values from functions. You might have to look into a composite return type or a row of data containing all of your values.

Note - comment converted to an answer at the OP's request

Sign up to request clarification or add additional context in comments.

Comments

1

Try:

RETURNS SETOF record

That should allow you to return any information you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.