function returns multiple columns as a single column instead of multiple columns

前端 未结 1 946
礼貌的吻别
礼貌的吻别 2020-12-03 05:29

I am currently writing a function in postgresql 9.04 where I am attempting to use a variable which will be used in a select statement then return the results.

The st

相关标签:
1条回答
  • 2020-12-03 06:02

    you need to call the function like this:

    select * from foo(6);
    

    which will return something like this:

    project_id | project_name | project_type | project_description | project_status
    -----------|--------------|--------------|---------------------|----------------
             6 | test project |      inbound |        inbound test |     processing
    

    it's a quirk of postgres that it can be called both ways and give you a result. you might want to check the docs on set returning functions some more, there are other ways to do this as well. Oh, there is a wiki page on it, written for plpgsql, but most applies to sql functions as well: http://wiki.postgresql.org/wiki/Return_more_than_one_row_of_data_from_PL/pgSQL_functions

    0 讨论(0)
提交回复
热议问题