0

I am experimenting with functions in PostgreSQL, and I got it working fine, but there is something confusing. I have this header of the function:

        CREATE OR REPLACE FUNCTION p.GetEvents(date) 
        RETURNS TABLE (when date,  participant varchar, helper varchar) 
        AS $$
        BEGIN
            (....)

And I thought this was going to return a table (hence the RETURN TABLE!) Something like this:

when    |    participant    |    helper
--------+-------------------+-----------
        |                   |

but instead is returning me the results looking like an array, such as:

(2015-03-21, participant, helper)
(2015-04-10, participant, helper)

Isn't RETURNS TABLE the right way to build a table as output? How can I force that the output is a table and not comma separated values?

2
  • 3
    Use select * from p.getevents(current_date). Commented May 31, 2015 at 12:43
  • whoops... that was it, I was calling the function without the * FROM... If you feel like typing an answer, I will accept it. Commented May 31, 2015 at 12:44

1 Answer 1

1

Use

select * from getevent(current_date);

because

select getevent(current_date);

returns rows with one column of pseudotype record.

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

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.