title: using Array_append gives me syntax error when creating PostgreSQL function
body: <p>Here is the code </p>
  
  <pre><code>CREATE OR REPLACE FUNCTION primes (IN   integer) RETURNS TEXT AS $$
  DECLARE
      counter INTEGER = $1;
      primes int [];
      mycount int;
    BEGIN
      WHILE counter != 0 LOOP
        mycount := count(primes);
        array_append(primes [counter], mycount);
        counter := counter - 1;
      END LOOP;
      RETURN array_to_text(primes[], ',');
    END;
  $$
  LANGUAGE 'plpgsql'
  </code></pre>
  
  <p>This is me developing the beginnings of a prime generating function. I am trying to simply get it to return the 'count' of the array. So if I pass '7' into the function I should get back [0, 1, 2, 3, 4, 5, 6].</p>
  
  <p>But when I try to create this function I get </p>
  
  <pre><code>SQL Error: ERROR:  syntax error at or near "array_append" LINE 1: array_append( $1  [ $2 ],  $3 )
          ^ QUERY:  array_append( $1  [ $2 ],  $3 ) CONTEXT:  SQL statement in PL/PgSQL function "primes" near line 8
  </code></pre>
  
  <p>I am a newbie with postgres functions. I am not understanding why I cannnot get this array to work properly.</p>
  
  <p>Again all I want is to just fill this array up correctly with the 'current' count of the array. (It's more to just help me understand that it is in fact doing the loop correctly and is counting it correctly).</p>
  
  <p>Thank you for your help.</p>