Select into temp table postgres. columns; RETURN QUERY SELECT * FROM my_temp .