0

我有以下代码,它适用于它提取的较小数据,但是当它遇到更大尺寸的记录时,它会出错。我将如何解决 ORA-01706:user function result value is too large 错误?

FOR r IN
          (SELECT Extract(Value(p),'pmt:PayInfo/pmt:Single', r_namespace) As Address,
          ExtractValue(Value(p),'pmt:PayInfo/pmt:Single/pmt:SingExtRef', r_namespace) AS extref,
          ExtractValue(Value(p),'pmt:PayInfo/pmt:Single/pmt:SingSequence', r_namespace) AS singseq
          FROM TABLE(XMLSequence(Extract(payXml,'/abcd:abcd/abcd:Pmt/pmt:Payments/pmt:PayInfo['||ctr2||']', r_namespace))) p
          )
          LOOP
          FOR row1 IN
            (SELECT ExtractValue(Value(l),'/pmt:SingAddInfo/cmn:AddInfoCmpType/text()', r_namespace) AS singtype,
    ExtractValue(Value(l),'/pmt:SingAddInfo/cmn:AddInfoCmpText[1]/text()', r_namespace) AS singtext1,
    ExtractValue(Value(l),'/pmt:SingAddInfo/cmn:AddInfoCmpText[2]/text()', r_namespace) AS singtext2,
          FROM TABLE(XMLSequence(Extract(r.Address,'/pmt:Single/pmt:SingAddInfo', r_namespace))) l
            )
            LOOP 
         IF (row1.singtype = 'IATCode')
         THEN
         r_iatcode := row1.singtext1;
         r_iatcode2 := row1.singtext2;
         ELSIF (row1.singtype = 'IndivID')
         THEN
         r_payor_identifier := row1.singtext1;
    END IF;
    END LOOP;
    END LOOP;

感谢您的时间!

4

1 回答 1

1

当你得到ORA-01706: user function result value was too large并使用EXTRACTVALUE()它是因为这个函数最多只能返回一个VARCHAR2(4000 CHAR)结果。

下面是一个简化的通用示例。

当遇到超过 4000 个字符的“VALUES”节点时,以下中断:

SELECT pk,
       EXTRACTVALUE(VALUE(xml), '*/VALUES') as vals
  FROM tableName a,
       TABLE (XMLSEQUENCE (EXTRACT (a.xmlFieldName, '/SOME/PATH/*'))) xml
 WHERE s.pk = 1         
   AND EXTRACTVALUE(VALUE(xml), '*/VALUES') IS NOT NULL;

改用以下语法,您可以定义您期望的 CLOB 结果,这将起作用:

SELECT pk,
       xml.vals
  FROM tableName a,
       XMLTable('/SOME/PATH/*'
                PASSING a.xmlFieldName
                COLUMNS vals     CLOB    PATH   'VALUES/text()') xml
 WHERE a.pk = 1
   AND xml.vals IS NOT NULL;

上述示例是当 XML 存储在表中的 XMLType 列中时。如果您使用的是本地 PL/SQL 变量而不是表,您可以执行以下操作:

SELECT xml.vals
  FROM XMLTable('/SOME/PATH/*'
                PASSING local_xmltype_variable
                COLUMNS vals     CLOB    PATH   'VALUES/text()') xml
 WHERE xml.vals IS NOT NULL;
于 2017-08-01T23:05:09.860 回答