Returns multiple rows from plpgsql function

I have the following function:

CREATE OR REPLACE FUNCTION function1() RETURNS TABLE(foo1 VARCHAR, foo2 VARCHAR) AS $$ BEGIN RETURN QUERY SELECT e.col1, e.col2 FROM my_table e; END; $$ LANGUAGE plpgsql; 

It returns something like this:

 function1 record |--------------| (a,b) (c,d) 

But I expect an analogue of the result of this type:

SELECT e.col1, e.col2 FROM my_table e;

  col1 col2 |-----|-----| ab cd 

Because I want to execute a get function, it separates the column values ​​in java resultSet and repeats them. Thank you

+6
source share
1 answer

You need to do

 select * from function1(); 
+5
source

Source: https://habr.com/ru/post/952905/


All Articles