title: How to get DB2 9.7 cursor value in for loop where returned value is a string
body: <p>I have a loop e.g.</p>
  
  <pre><code>DECLARE SQL VARCHAR(1024);
  
  FOR V AS CUR1 CURSOR FOR (SELECT 'Select * from My_Table' from ... )
  DO
      SET SQL = CUR1;
      PREPARE S1 FROM SQL;
      EXECUTE S1;
  END FOR;
  </code></pre>
  
  <p>This does not seem to work. I have successfully done similar to this when the cursor in the for loop points to some row returned and I can access the value e.g. like this:</p>
  
  <pre><code>SET SQL = CUR1.TABNAME
  </code></pre>
  
  <p>But now that the returned value is a string, I have no idea how to get it from the cursor. Any ideas? </p>