title: PL/pgSQL: accessing fields of an element of an array of custom type
body: <p>I've defined a custom type:</p>
  
  <pre><code>create type pg_temp.MYTYPE as (f1 int, f2 text);  
  </code></pre>
  
  <p>Then, inside a function or a block, I've declared an array of such type:</p>
  
  <pre><code>declare ax MYTYPE[];
  </code></pre>
  
  <p>I can access an element through the familiar syntax <code>ax[1].f1</code>, but just for reading it.<br>
  When I use the same syntax for setting the field, I get a syntax error. </p>
  
  <pre><code>create type pg_temp.MYTYPE as (f1 int, f2 text);
  
  do $$
  declare x MYTYPE;
  declare ax MYTYPE[];
  declare f int;
  begin
  
      x.f1 = 10;
      x.f2 = 'hello';
  
      --assigning an element: OK
      ax[1] = x;
  
      --reading an element's field: OK
      f = ax[1].f1;
  
      --writing an elememt's field: SYNTAX ERROR: 
  
      ax[1].f1 = f;
  
  end; $$
  </code></pre>
  
  <p>The error is the following:</p>
  
  <pre><code>psql:test.sql:28: ERROR:  syntax error at or near "."
  LINE 20:  ax[1].f1 = f;
            ^
  </code></pre>
  
  <p>I've tried also the syntax <code>(ax[1]).f1</code> with the same result.<br>
  Which is the correct syntax to do this?</p>
  
  <p>Postgres server version: 9.2.2</p>