2014-04-12 158 views
2

在我的存储过程:的XMLType字符串缓冲区太小

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你大家有什么想法如何去做这件事?谢谢

+0

不应该是xmlelement(“el2”)'和类似的“el”吗?你的桌子上有多少行? – Yavor

回答

0

也许你正在使用旧的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; 
2

如果使用xmlagg(),你就必须添加.getclobval()到周围xmlelement()由于焦炭极限是4000上xmlagg()。显然这意味着你将使用clobs而不是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;