如何将超过 4000 个字节字符的 XML 插入到 Oracle 数据库 11.2.0.4.0 gr2 的 Oracle XMLTYPE 列中

问题描述 投票:0回答:1

我试图将超过 4000 个字节字符的 XML 插入到 Oracle XMLTYPE 列中,但出现此错误: ora-06502: pl/sql: 数字或值错误: 字符串缓冲区太小

我尝试在我的 oracle 版本 11gr2 中“set max_string_size='EXTENDED'” 但他们没有参数名称 max_string_size

xml oracle xmltype
1个回答
0
投票

如果您在查询中使用字符串文字,则每个文字的长度不能超过 4000 字节。您需要将字符串文字拆分成块并将它们连接在一起,确保第一个文字要么包装在

TO_CLOB
中,要么附加到 CLOB:

CREATE TABLE table_name (xml XMLTYPE);
INSERT INTO table_name (xml)
VALUES (
  XMLTYPE(
   TO_CLOB('<root>First 4000 bytes ...')
    || 'Second 4000 bytes ...'
    || 'Third 4000 bytes ...'
    || 'Etc. ...</root>'
  )
);

或:

INSERT INTO table_name (xml)
VALUES (
  XMLTYPE(
    EMPTY_CLOB()
    || '<root>First 4000 bytes ...'
    || 'Second 4000 bytes ...'
    || 'Third 4000 bytes ...'
    || 'Etc. ...</root>'
  )
);

小提琴

© www.soinside.com 2019 - 2024. All rights reserved.