title: PostgreSQL ALTER SEQUENCE in function
body: <p>I have trigger function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION update_aaa() RETURNS TRIGGER AS $$
  DECLARE maxid INTEGER;
  BEGIN
      SELECT MAX(id) INTO maxid FROM aaa;
      ALTER SEQUENCE aaa_id_seq RESTART WITH maxid;
  END;
  $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>And have error:</p>
  
  <pre><code>ERROR:  syntax error at or near "$1"
  Line 1: ALTER SEQUENCE aaa_id_seq RESTART WITH  $1 
  </code></pre>
  
  <p>Why $1 ?<br>
  What error?</p>