query has no destination for result data
/* 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;