title: How to declare an array of rowtype in a PostgreSQL function?
body: <p>I am trying to create a PostgreSQL function where I will loop over the rows of a query and store some of them in an array, before doing more stuff with it. How can I create an array of rowtype?</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION forExample() RETURNS integer AS
  $BODY$
  DECLARE
      r "WEBHOST"%rowtype;
      b "WEBHOST"%rowtype[];   &lt;- This does not work !!!
  BEGIN
      FOR r IN SELECT * FROM "WEBHOST"
      LOOP
          array_append(b, r);
      END LOOP;
      RETURN 33;
  END
  $BODY$
  LANGUAGE 'plpgsql';
  </code></pre>
  
  <p>The above function will be more complex, but I am providing a simplified version for this question.</p>