title: Building some dynamic query select and display its output immediately in Oracle PL/SQL
body: <p>in my actual job I need, very often, to read some tables and acting consequently, sometimes updating these data manually.
  So I built a PL/SQL block that creates my SELECT statements (yes, with the "FOR UPDATE" clause, just commented).
  As an example, this is <strong>just one</strong> of the queries I build:</p>
  
  <pre><code>phtr_QUERY := 'SELECT *
   FROM   ' || tabriabi_impianto || '.pdfhtr t 
   WHERE t.k_abi=''' || tabriabi_abi || ''' ';
  
  if length(myNag) &gt; 0 then
   phtr_QUERY := phtr_QUERY || 'and t.ndg like ''%' || myNag || '%'' ';
  end if;
  
  if length(myPrat) &gt; 0 then
    phtr_QUERY := phtr_QUERY || ' and t.pratica like ''%' || myPrat || '%'' ';
  end if;
  phtr_QUERY := phtr_QUERY || crlf || ' order by 2 ';
  phtr_QUERY := phtr_QUERY || crlf || '--for update';
  phtr_QUERY := phtr_QUERY || crlf || ';';
  </code></pre>
  
  <p>Then I copy these statements from the Output window (obtained through the dbms_output.put_line) and paste it into a new SQL Window and executing it, obtaining the results in multiple tabs.</p>
  
  <p>I was wondering if there is a better way, some commands that I can use just to have the (editable) results directly without the need of cut&amp;paste...</p>
  
  <p>TIA.</p>
  
  <p>F.</p>