title: oracle plsql chunking the rows
body: <p>I have a select statement which returns 0 or more rows. </p>
  
  <p>I'm trying to come up with a plsql proc with a cursor to produce xml output fro, all rows returned into 100 rows at a time. i'm doing this to chunk loo rows at a time based on requirement.  </p>
  
  <p>So basically my program should follow below logic </p>
  
  <pre><code>cursor c1 is select id,code_id,code_desc from table order by id; --returns some rows  
  
  if c1%notfound
    then return;` -- exit from procedure 
  else
  loop
    grab first 100 rows from select and append to a variable
    and assign it to a variable; 
    update this variable into a clob field in a table. 
    grab next 100 rows and append into a variable
    update this variable into a clob field in a table in another row;see below 
    table data 
  
     and so on
     and grab remaining rows and append into a variable 
     print the variable;
  until no data found;
  exit
  </code></pre>
  
  <p>I'm trying to do convert the output from select statement into xml text. </p>
  
  <p>The output should look something like below: </p>
  
  <p>TABLE: STG_XML_DATA </p>
  
  <pre><code>LOOP_NO(NUMBER), XML_TEXT(CLOB), ROWS_PROCESSED
  1                &lt;XML&gt;&lt;id&gt;1&lt;/ID&gt;&lt;id&gt;2&lt;/ID&gt;..&lt;ID&gt;100&lt;/ID&gt;&lt;/XML&gt;     100
  2                &lt;XML&gt;&lt;id&gt;101&lt;/ID&gt;&lt;id&gt;102&lt;/ID&gt;..&lt;ID&gt;200&lt;/ID&gt;&lt;/XML&gt; 200 
  3                &lt;XML&gt;&lt;id&gt;301&lt;/ID&gt;&lt;id&gt;102&lt;/ID&gt;..&lt;ID&gt;320&lt;/ID&gt;&lt;/XML&gt; 20
  </code></pre>
  
  <p>Can someone please help</p>