title: Listagg function and ORA-01489: result of string concatenation is too long
body: <p>When i run the following query:</p>
  
  <pre><code> Select
    tm.product_id,
    listagg(tm.book_id || '(' || tm.score || ')',',')
      within group (order by tm.product_id) as matches
  from
    tl_product_match tm 
  where
    tm.book_id is not null 
  group by
    tm.product_id
  </code></pre>
  
  <p>Oracle returns the following error:</p>
  
  <pre><code> ORA-01489: result of string concatenation is too long
  </code></pre>
  
  <p>I know that the reason it is failing is that the listagg function is trying to concatenate a the values which are greater than 4000 characters which is not supported. </p>
  
  <p>I have seen the alternative example described here - <a href="http://www.oracle-base.com/articles/misc/string-aggregation-techniques.php">http://www.oracle-base.com/articles/misc/string-aggregation-techniques.php</a> but they all require the use of functions or procedure. </p>
  
  <p>Is there a solution that is pure SQL without having to call a function or stored procedure and being able to read the value using standard JDBC? </p>
  
  <p>The other difficulty i have is that most string aggregation examples i have seen shows examples with how to read the value as is. In my example about i am modifying the value first (i.e. i am aggregating two columns). </p>