title: Firebird stored procedure array datatypes
body: <p>I'm trying to solve a problem in a Firebird stored procedure.  I need to read some records from a table, (FOR SELECT...BEGIN   END) and, after changing things around, INSERT some of them back into the same table (new record), within the BEGIN END loop.</p>
  
  <ul>
  <li><p>Unless I misunderstand it, the simplest way would be to use a cursor, but I just can't find out how to do it, either by trial and error, or from the internet.</p></li>
  <li><p>Another approach would be to use an in-memory array (not a table datatype, but a PSQL datatype declared in the stored procedure). The problem is the same as above.</p></li>
  <li><p>The third seems to be to use a Global Temporary Table - unfortunately it seems that they can't be used in a single SQL statement with 'normal' tables, so I can't copy the results to the original table.</p></li>
  <li><p>The final approach is to create a table and use it as an intermediary - I just don't like this approach. I'll do it if there's no other solution</p></li>
  </ul>
  
  <p>In short, can anyone help me with how to select some rows from a table (with other tables in the selection), and write back to the same table?</p>
  
  <p>thanks</p>
  
  <p>steve</p>
  
  <p>ps doing just FOR SELECT BEGIN... INSERT ... END results in a never ending loop.</p>