Listagg function and ORA-01489: result of string concatenation is too long

前端 未结 3 1731
萌比男神i
萌比男神i 2020-12-17 18:56

When i run the following query:

 Select
  tm.product_id,
  listagg(tm.book_id || \'(\' || tm.score || \')\',\',\')
    within group (order by tm.product_id)          


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-17 19:29

    you can use xml functions to do it which return a CLOB. JDBC should be just fine with that.

    select tm.product_id, 
           rtrim(extract(xmlagg(xmlelement(e, tm.book_id || '(' || tm.score || '),')), 
                   '/E/text()').getclobval(), ',')
      from tl_product_match tm
     where tm.book_id is not null 
     group by tm.product_id;
    

    eg: http://sqlfiddle.com/#!4/083a2/1

提交回复
热议问题