查询返回 - > ORA-19011:字符串缓冲区太小

时间:2014-12-16 13:42:23

标签: oracle

我在下面运行此查询,并且oracle返回以下消息:查询返回 - > ORA-19011:字符串缓冲区太小 当我取消注释最后一行时,它可以工作。我认为这就是为什么这会导致很少的结果。怎么解决这个?

 select substr(xmlagg(xmlelement (e, str||',')).extract ('//text()'),1,(Length(Trim(xmlagg (xmlelement (e, str||',')).extract ('//text()')))-2)) motivos
     FROM (
           select to_char(lo_valor) str
             from editor_layout el,
                  editor_versao_documento ev,
                  editor_documento ed,
                  editor_layout_campo elc,
                  editor_campo ec,
                  editor_registro er,
                  editor_registro_campo erc,
                  pw_editor_clinico pec,
                  pw_documento_clinico pdc
            where pec.cd_editor_registro   = er.cd_registro
              and pdc.cd_documento_clinico = pec.cd_documento_clinico
              and ed.cd_documento          = ev.cd_documento
              and el.cd_versao_documento   = ev.cd_versao_documento
              and el.cd_layout             = elc.cd_layout
              and elc.cd_campo             = ec.cd_campo
              and elc.cd_campo             = erc.cd_campo
              and er.cd_registro           = erc.cd_registro
              and er.cd_layout             = el.cd_layout
              and ec.ds_identificador = 'nut_orientacoes_entregues_1'
              AND To_Char(lo_valor) IS NOT null
              --and Trunc(pdc.dh_documento) BETWEEN Trunc(SYSDATE-5) AND Trunc(SYSDATE)
          )

1 个答案:

答案 0 :(得分:0)

xmlagg(xmlelement ...)来电的内容会返回clob,您尝试将其填入varchar2,因为您拨打了substr。如果clob太大,那将失败。

取消注释最后一行时失败的原因是在该范围之外,存在内容太长的行。