title: Dynamic SELECT INTO in PL/pgSQL function
body: <p>How can I write a dynamic <code>SELECT INTO</code> query inside a PL/pgSQL function in Postgres? </p>
  
  <p>Say I have a variable called <code>tb_name</code> which is filled in a <code>FOR</code> loop from <code>information_schema.tables</code>. Now I have a variable called <code>tc</code> which will be taking the row count for each table. I want something like the following:</p>
  
  <pre><code>FOR tb_name in select table_name from information_schema.tables where table_schema='some_schema' and table_name like '%1%'
  LOOP
  EXECUTE FORMAT('select count(*) into' || tc 'from' || tb_name);
  END LOOP
  </code></pre>
  
  <p>What should be the data type of <code>tb_name</code> and <code>tc</code> in this case?</p>