title: Can an oracle SQL query execute a string query selected from a table?
body: <p>When using oracle SQL is it possible to run a query based on a text_string from a subquery?
  An example might clarify what I'm trying to do</p>
  
  <pre><code>    select count(sql_text), sql_text
      from
          (select sql_text 
          from query_table) sql_table
      group by sql_text;
  </code></pre>
  
  <p>The outer query is intended to count the number of results for each query retrieved from the query_table.</p>
  
  <p>Is there some way I can execute the sql statements I retrieved from my query_table in the same query?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:
     I was able to query sql from a table using the dbms_xmlgen.get_xml() function.  I suppose that any command which caused the sql to be parsed and executed would work.
  That being said, here's the generic code that I was able to accomplish things with:</p>
  
  <pre><code>    select  to_number (
          extractvalue(
          xmltype(
          dbms_xmlgen.getxml('select count(*) c from '|| table_name)), '/ROWSET/ROW/C'))counter,
          sql_text
      from
          (select '('||sql_text||')' table_name 
          from query_table) sql_table;
  </code></pre>
  
  <p>While perhaps not the most elegant way to do things, it works and is a single sql statement.</p>