title: How can I get multiple listagg rows for a certain number of records?
body: <p>As you probably know, <a href="http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions089.htm#SQLRF30030" rel="nofollow noreferrer">LISTAGG</a> allows you to concatenate values from multiple rows into a single value.</p>
  
  <p>I'm trying to build a regular expression from multiple rows, and then extract it to be used in other applications to search for files.</p>
  
  <p>However, <a href="https://stackoverflow.com/questions/2694023/oracle-determine-maximum-supported-size-for-regular-expression">there is a limit on the maximum length of regular expressions in Oracle (512 bytes)</a>.</p>
  
  <p>For this reason, I need to get multiple rows with a separate listagg, and then export that output.</p>
  
  <pre><code>--The output I need is multiple rows with a listagg on 50 rows each
  
  select '^.*(' || listagg(id, '|') within group (order by id) || ')' regex
  from mytable
  --where rownum &lt; 50  
  </code></pre>
  
  <p>Here's where I'm stuck. Is it possible?</p>