【问题标题】:xmltype character string buffer too smallxmltype 字符串缓冲区太小
【发布时间】:2014-04-12 07:28:17
【问题描述】:

在我的存储过程中:

 declare
v_xml xmltype;
begin
open v_cur for
Select xmlelement('el',xmlagg(xmlelement('el2'))) from table;
loop
fetch v_cur into v_xml; -- line where the error 

*.....additional logic to parse v_xml*
end loop;
end;

当要提取到 v_xml 的记录长度 > 4000 时,我收到“字符串缓冲区太小”错误。你们知道如何解决这个问题吗?谢谢

【问题讨论】:

  • 不应该是be xmlelement("el2")"el" 类似吗?您的表中有多少行?

标签: oracle xmltype


【解决方案1】:

如果您使用xmlagg(),则必须将.getclobval() 添加到周围的xmlelement(),因为xmlagg() 的字符限制为4000。显然这意味着您将使用 clob 而不是 xmltype 但您别无选择,如果需要,您必须稍后再转换回 xmltype。示例如下:

declare
v_xml clob; -- Use CLOB
begin
open v_cur for
Select xmlelement("el",xmlagg(xmlelement("el2", tab_col))).getclobval() from table; -- add .getclobval()
loop
fetch v_cur into v_xml; -- line where the error 

*.....additional logic to parse v_xml*
end loop;
end;

【讨论】:

    【解决方案2】:

    也许您使用的是旧的 Oracle 版本?过去有一些限制。对我来说,它适用于 10 000 000 行:

    declare
        v_xml xmltype;
    begin
        select xmlelement("el", xmlagg(xmlelement("el2")))
        into v_xml from (select 1 from dual connect by level <= 10000000);
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-08
      • 1970-01-01
      • 2012-11-11
      • 1970-01-01
      相关资源
      最近更新 更多