title: How can I use join for returned result?
body: <p>Now I have the following function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION set_city(_city_id bigint, _country_id integer, _lat float, lon float) RETURNS geo_cities LANGUAGE plpgsql as $$
      DECLARE
              city_coords Geometry := ST_SetSrid(ST_MakePoint(_lon, _lat), 3395);
              result record;
      BEGIN
              IF EXISTS (SELECT 1 FROM geo_cities gc WHERE gc.id = _city_id)
              THEN
                      UPDATE geo_cities
                      SET coords = city_coords, country_id = _country_id
                      WHERE id = _city_id
                      RETURNING * INTO result;
              ELSE
                      INSERT INTO geo_cities(id, country_id, coords)
                      VALUES (_city_id, _country_id, city_coords)
                      RETURNING * INTO result;
              END IF;
              RETURN result;
      END;
   $$
  </code></pre>
  
  <p>I want to use join with my result. That's what I mean:</p>
  
  <pre><code>  ...
    RETURNING 
      id as city_id,
      ST_X(coords) as lon,
    INNER JOIN geo_countries as gc ON gc.id = id
    ... 
  </code></pre>
  
  <p>Can I do that?</p>