I am writing a function in PostgreSQL 9.04 attempting to use a variable which will be used in a select statement then return the results.
The statement I have is simple and works; however, all the columns are outputing to a single column instead of multiple columns.
My function:
create or replace function foo(IN pID integer, OUT project_id integer, OUT project_name text, OUT project_type text, OUT project_description text, OUT project_status text)
returns setof record as
$$
select project_id, project_name, project_type, project_description, project_status from t_projects
where project_id = $1;
$$
LANGUAGE SQL;
select foo(6) -- runs function
The current output looks like this:
"(6,"test project","inbound","inbound test","processing")"
How can I make it so the results are not concatenated together and return each column item separately?
setof recordwhile also declaringOUTcolumns that match theSELECT? Do you intend to return records, or populate theOUTparameters? You should pick one approach, not both.