title: ERROR schema does not exist
body: <pre><code>CREATE OR REPLACE FUNCTION analyzeTables()
    RETURNS INT AS $$
  DECLARE
    v_rec information_schema.tables%ROWTYPE;
  BEGIN
    FOR v_rec IN
    SELECT *
    FROM information_schema.tables mytable
    WHERE mytable.TABLE_SCHEMA = 'public'
          AND mytable.table_type = 'BASE TABLE'
    ORDER BY mytable.table_name
    LOOP
      ANALYZE v_rec.table_name;
    END LOOP;
    RETURN 0;
  END;
  $$
  LANGUAGE plpgsql;
  
  SELECT * FROM analyzeTables();
  </code></pre>
  
  <p>results in ERROR schema "v_rec" does not exist Where SQL statement <code>"ANALYZE v_rec.table_name"</code>.
  As you can see I'm trying to analyze some tables within a function and it's not interpreting v_rec correctly it thinks it's a schema name when I trying to return the table name I want to analyze <code>i.e ANALYZE</code> fuel_station. Have tried with and without mytable alias and declared using both <code>%ROWTYPE</code> and <code>RECORD</code> makes no difference same error. What am I doing wrong?</p>