oracle sql将数据拼接导出(ORA-01489: result of string concatenation is too long)

关键字:plsql、oracle、listagg、xmlagg、<CLOB>、ORA-01489: result of string concatenation is too long

  1. 在使用listagg将数据拼接查询时报错,以下是原本的sql

 select tu.unit_name ,
        th.heating_name  ,
        tu.legal_person_landline  ,
        listagg(td.road||td.cell_name||td.building_name, ',') within group(order by td.heating_source_id) 
   from t_heating_souce_base th
  inner join t_heating_unit_baseinfo tu
     on th.unit_id = tu.id
  inner join T_R_BUILDING_DETAILS td
     on td.heating_source_id = th.id
  inner join t_administrative_code tc
     on tc.code = td.county
  where th.is_delete = '0'
    and td.is_delete = '0'
  group by tu.unit_name ,
        th.heating_name  ,
        tu.legal_person_landline
 
  1. 说字段过长ORA-01489: result of string concatenation is too long

  1. 所以使用xmlagg查询数据

 select tu.unit_name ,
        th.heating_name  ,
        tu.legal_person_landline  ,
        xmlagg(xmlparse(content td.road||td.cell_name||td.building_name || ',' wellformed) ORDER BY td.heating_source_id).getclobval()
   from t_heating_souce_base th
  inner join t_heating_unit_baseinfo tu
     on th.unit_id = tu.id
  inner join T_R_BUILDING_DETAILS td
     on td.heating_source_id = th.id
  inner join t_administrative_code tc
     on tc.code = td.county
  where th.is_delete = '0'
    and td.is_delete = '0'
  group by tu.unit_name ,
        th.heating_name  ,
        tu.legal_person_landline
  1. plsql工具查询到的数据是<CLOB>,这时候我们不管是复制数据,还是右键点击复制后导出指定文件都不行,他会将<CLOB>原样导出,这时候我们需要点击导出查询结果按钮进行导出即可。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值