oracle - xmltype 字符串缓冲区太小

标签 oracle 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 时,我收到“字符串缓冲区太小”错误。你们知道如何解决这个问题吗?谢谢

最佳答案

如果您使用 xmlagg(),则必须将 .getclobval() 添加到周围的 xmlelement(),因为 char 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;

关于oracle - xmltype 字符串缓冲区太小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23027540/

相关文章:

c# - "ORA-00933: SQL command not properly ended"使用 Oracle.ManagedDataAccess

sql - ORACLE条件选择多行

sql - 在 where 子句中使用 Oracle SQL 变量时出现问题

sql - Oracle XPath : Parent Node Attribute?

Oracle 从 xmltype 中提取值

sql - 如何选择名称之间有空格的列

sql - 如何将 IN 运算符与 LIKE 条件结合起来(或获得可比较结果的最佳方法)

java - 如何管理H2数据库上的XmlType

xml - 从 XML 到 Oracle PL/SQL 环境中的路径列表

java - JAXB Schemagen(v.7.0.450.18): change XmlElement name and XmlType(propOrder={. ..})