title: Select in a cursor in DB2
body: <p>I have to fetch all columns names for all tables in a specific schema.</p>
  
  <p>I did it without any problem in PL/SQL for an oracle Database but in DB2 I can't seem to make it work.</p>
  
  <p>Here is my code : </p>
  
  <pre><code>BEGIN
  declare cur1 cursor for
      select TABNAME 
      from syscat.tables 
      where tabschema = 'SchemaX';
  
  open cur1;
  fetch cur1 into i;
  while SQLCODE &lt;&gt; 100
   do
     select * from SYSCAT.COLUMNS where tabname = i;
  end while;
  close cur1;
  END
  </code></pre>
  
  <p>it doesn't seems to like my select in the while loop. </p>
  
  <p>Anybody have done this before?</p>
  
  <p>Thank you!</p>