title: Postgres how to evaluate expression from query to variables in the function
body: <p>I would like to be able to get values of function variables whose names are queried from a table</p>
  
  <p>Edited to show querying a table instead of query from static values:</p>
  
  <pre><code>    create table __test__
  (
  _col text
  );
  insert into __test__
  (_col)
  values('_a');
  
     create or replace function __test() 
      returns void
      language 'plpgsql' as
      $$
      declare
        _r record;
        _a int;
        _b int;
        _sql text;
      begin
  
        _a = 1;
        _b = 0;
  
        for _r in select _col as _nam from __test__ a loop
        -- query returns one row valued "_a"
          _sql = 'select ' || _r._nam ;
          execute _sql into _b;
        end loop;
  
        raise info 'value of _b %', _b;
  
      end;
      $$;
  select __test()
  </code></pre>
  
  <p>when function executes so that _b = 1. Is it possible?</p>
  
  <p>same error ...</p>
  
  <pre><code>ERROR:  column "_a" does not exist
  LINE 1: select _a
                 ^
  QUERY:  select _a
  CONTEXT:  PL/pgSQL function "__test" line 15 at EXECUTE statement
  </code></pre>