title: PL/pgSQL COPY variable FROM STDIN
body: <p>I have the following script:</p>
  
  <pre><code>DO $$
  DECLARE
      i INTEGER;
  BEGIN
  
      i := 5;
  
      COPY public.mytable (id, name) FROM stdin;
      i   abc
      \.
  
  END $$;
  </code></pre>
  
  <p>I run the above script using psql. I want to take the value from the variable <code>i</code> and use it in the <code>COPY</code> command. How can I do this in PL/pgSQL? Can \echo be used?</p>