Postgresql function not returning a table on select

前端 未结 1 591
迷失自我
迷失自我 2021-01-28 15:51

I have the following postgresql function in which i am trying to return 2 parameters named campusid and campusname.

CREATE OR REPLACE FUNCTION getall(IN a charac         


        
相关标签:
1条回答
  • 2021-01-28 16:15

    You must have a destination for the selects, and the function must return a value. Just a SELECT statement does neither. The only use of such a statement, generally, is to test permissions, or make a trigger run, for which the results are not used. You will need to use one of the family of RETURN statements, to get values from the function.

    RETURN QUERY( SELECT * from "SIS_campus" );
    

    That will add the results of that query to the function's returning results, and should do what you're after, since you only can return 0 or 1 results. You may need to add a simple RETURN at the very end of the function, as well (despite the docs, I've not quite grokked when that is or isn't needed, myself).

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