xxxxxxxxxx
-- You just need to return a query instead of "returning id"
--example:
CREATE OR REPLACE FUNCTION my_function()
RETURNS table (id int)
LANGUAGE plpgsql
AS
$$
BEGIN
.
RETURN query (SELECT id from my_table where .);
END;
$$
xxxxxxxxxx
/* you cannot junt do the select, you're supposed to use it in
the return as the code below */
CREATE OR REPLACE FUNCTION fun() RETURNS text AS $$
BEGIN
--- .
RETURN(SELECT dblink_disconnect());
END
$$ LANGUAGE plpgsql;