在将XMLAGG与关联数组一起使用时,为什么我达到了限制?

时间:2014-06-05 16:57:48

标签: xml oracle plsql oracle11g associative-array

注意,我的问题太长了,所以我粘贴了代码here

这是在Oracle 11gR2上。这个问题涉及使用XMLAGG来连接在关联数组上运行的查询的输出。 我最近提出的另外两个问题是:Is Oracle's EXTRACT function breaking the NOENTITYESCAPING in the XMLELEMENT?What data structure to use in order to sort this data in PL/SQL?

如果您在上面的粘贴bin链接中运行代码,您将获得精彩的 ORA-06502:PL / SQL:数字或值错误,但如果您注释掉该行从 sorting_table(578)开始,代码运行正常(返回一个非常长的连接字符串)。显然它已经达到某种内部Oracle限制,但我对它的含义感到困惑。我的理解是这里涉及的所有数据类型都是CLOBS,这是不正确的?建议的解决方法是什么?

select xmlagg(xmlelement(e,stringval, valueSeparator).extract('//text()') order by upper(intval)).GetClobVal()
  into lv_value
  from table(sorting_table);

1 个答案:

答案 0 :(得分:1)

好的,好消息是,这不是由SQL导致的:它是后续的DBMS_OUTPUT调用失败,因为它在行注释掉时运行:

589
590       -- DBMS_OUTPUT.put_line('lv_value='||lv_value);
591*     END;

PL/SQL procedure successfully completed.

SQL> @monster_xml
    DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 590

SQL> 

现在,根据文档,maximum line size is 32767。我更正了DBMS_OUTPUT调用以显示字符串的长度,它就在其中:

SQL>  @monster_xml
lv_value=32707

PL/SQL procedure successfully completed.

SQL> 

所以看起来你可能在11gR2中遇到了DBMS_OUTPUT中的Oracle错误。