title: Insert PostGIS Object (e.g. ST_GeomFromText) from row variables in plpgsql script
body: <p>I have two tables src_pos and dest_pos.</p>
  
  <p>The src_pos stores positions with longitude, latitude and altitude, while the dest_pos stores PosGIS Geometry object.</p>
  
  <p>Now I want to move a bunch of data from src_pos to dest_pos with following plpgsql script.
  But it failed, because row vaiable (e.g. row_data.longitude) cannot be interpreted correctly.
  How can I overcome this problem!? </p>
  
  <pre><code>--create language 'plpgsql';
  drop function createPosition();
  create function createPosition() returns integer AS 
  $$
    DECLARE 
      updated INTEGER = 0;
      row_data src_pos%ROWTYPE;       
    BEGIN 
      FOR row_data IN SELECT * FROM src_pos
      LOOP
          INSERT INTO dest_pos (coord) VALUES (ST_GeomFromText('POINT(row_data.longitude row_data.latitude row_data.altitude)', 4326));
          updated := updated + 1;
      END LOOP;
      RETURN updated;
    END;
  $$
  LANGUAGE 'plpgsql';
  </code></pre>