title: dynamically generate sql insert statements from results of a query
body: <p>I have to generate a series of insert statements based on the results of a query for a db2 and oracle databases.  In practice from a query like this  </p>
  
  <pre><code>select g.id from SUV_OWNER.gruppi g 
  WHERE EXISTS (SELECT 1 FROM SUV_OWNER.GRUPPIRUOLIPROCEDURE grp WHERE grp.gruppoid=g.gruppoid 
  AND GRP.RUOLOID = 50)
  AND 
  G.CHIAVE LIKE 'ANA%';
  </code></pre>
  
  <p>which generates as output a sequence of numbers not known in advance as  </p>
  
  <pre><code>30000  
  30001  
  .....  
  </code></pre>
  
  <p>I have to generate for each number an insert statement as  </p>
  
  <pre><code>insert into SUV_OWNER.GRUPPIRUOLIPROCEDURE (GRUPPOID, RUOLOID, PROCEDURAID) values  (30000, 141, 7);  
  insert into SUV_OWNER.GRUPPIRUOLIPROCEDURE (GRUPPOID, RUOLOID, PROCEDURAID) values  (30001, 141, 7);
  </code></pre>
  
  <p>I'm a newbie in sql, how can i generate this sequence of inserts ?</p>
  
  <p>Thanks for your help</p>