title: Oracle Convert table rows to list
body: <p>I have a table A with single column </p>
  
  <pre><code> **TableA**
    Row1
    Row2
    Row3
    .....
  </code></pre>
  
  <p>I have to convert the table rows into a list and store them in variables. So that they are stored as</p>
  
  <pre><code>Row1,Row2,Row3,....,Rown
  </code></pre>
  
  <p>I used the listagg () function to achieve the solution.</p>
  
  <pre><code>DECLARE
  tbl_list CLOB; 
  
  BEGIN
  
  SELECT  listagg (''''||Column_name||'''',',') WITHIN GROUP (ORDER BY Column_name) INTO TBL_LIST FROM TableA;  
  END;
  </code></pre>
  
  <p>This works fine if the TableA has few rows. But if the table has lots of rows I get the following error</p>
  
  <pre><code>ORA-01489: result of string concatenation is too long
  </code></pre>
  
  <p>Is this due to the storage limit of variable TBL_LIST? Can anyone explain me what is wrong. And is there an alternate for lisagg(), to achieve the result, I want?</p>