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?
select * from p.getevents(current_date).