title: plpgsql: concatenation of variable into FROM clause
body: <p>I'm new to Postgresql and struggling to build a function for looping over a series of CSV files and loading them. I can make the COPY work just fine with a single file, but I'm unable to get the FOR LOOP syntax correct. I'm trying to substitute a year number as my flies are named /path/tmp.YEAR.out.csv </p>
  
  <p>This is what I've hacked up:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION test() RETURNS void as $$
  BEGIN
    FOR i IN 1982..1983 LOOP
      COPY myTable 
      FROM '/path/tmp.' || i::VARCHAR || '.out.csv'
      delimiters ','
    END LOOP;
  END;
  $$ LANGUAGE 'plpgsql';
  </code></pre>
  
  <p>This throws an error at the first ||. So I suspect I'm managing the concat of the variable <code>i</code> improperly. Any tips?</p>