title: IBM DB2 ODBC Driver Issue [Error 69899] Error occurred in the database host server code. SQLSTATE= S1000
body: <p>After upgrade our IBM System i (aka i5/OS or AS/400) from V5R4 to V7R1, one of our applications that connect to DB2 using ODBC fails with the following error:</p>
  
  <pre><code>Error Code: 69899
  SQLSTATE: S1000
  [IBM] [System i Access ODBC Driver] [DB2 for i5/OS] PWS0005 
  Error occurred in the database host server code.
  </code></pre>
  
  <p>The symptoms are:</p>
  
  <p>In a While / Wend loop a CURSOR is declared, then opens, do fetch(s) and close.</p>
  
  <p>If at any iteration the cursor does not retrieve any rows, in the following iteration the error occurs after declaring the cursor (with a different SQL query) when you try to open it.</p>
  
  <p>First we updated the ODBC driver to the latest version available, but the problem persists.</p>
  
  <p>Because we needed an urgent solution, I solved the problem by making a pre-select to determine if the cursor will return rows, otherwise skip that iteration, this solves the problem for now but does not seem a very elegant solution.</p>
  
  <p>Any idea how to get more information about the error that occurs on the host?</p>
  
  <p>Thank you very much in advance.</p>