简体   繁体   English

如何将blob转换为clob或如何在oracle中为BLOB使用extractValue函数

[英]How to convert blob to clob or how to use extractValue function for BLOB in oracle

I tried using BLOB datatype in extractValue() to fetch text in specified XPATH, but its throwing error for BLOB data type where it is working fine for CLOB data type.我尝试在extractValue() 中使用BLOB 数据类型来获取指定XPATH 中的文本,但是它对于BLOB 数据类型的抛出错误,它对于CLOB 数据类型工作正常。

So I tried to convert BLOB to CLOB with below logic as got from stackoverflow所以我尝试使用以下逻辑将 BLOB 转换为 CLOB,如从 stackoverflow 获得的

    create function clobfromblob(p_blob blob) return clob is
      l_clob         clob;
      l_dest_offsset integer := 1;
      l_src_offsset  integer := 1;
      l_lang_context integer := dbms_lob.default_lang_ctx;
      l_warning      integer;

   begin

      if p_blob is null then
         return null;
      end if;

      dbms_lob.createTemporary(lob_loc => l_clob
                              ,cache   => false);

      dbms_lob.converttoclob(dest_lob     => l_clob
                            ,src_blob     => p_blob
                            ,amount       => dbms_lob.lobmaxsize
                            ,dest_offset  => l_dest_offsset
                            ,src_offset   => l_src_offsset
                            ,blob_csid    => dbms_lob.default_csid
                            ,lang_context => l_lang_context
                            ,warning      => l_warning);

      return l_clob;

   end;

after using above function I am getting output in unreadable format.使用上述功能后,我以不可读的格式输出。 Please help in how to convert blob to clob in readable format or how to use extractValue() for BLOB messages请帮助了解如何将 blob 转换为可读格式的 clob 或如何将 extractValue() 用于 BLOB 消息

您可以使用包含许多函数来处理 BLOB/CLOB 等的包 OraOpenSource Utils链接

1) Error: PLS-306: wrong number or types of arguments. 1) 错误:PLS-306:参数数量或类型错误。 Xmltype 's constructor for blob data is expecting two parameters. Xmltype 的 blob 数据构造函数需要两个参数。 xmltype(blob,csid)

cisd - character set ID of the blob data SELECT NLS_CHARSET_ID('UTF8') csid FROM DUAL; cisd - blob 数据的字符集 ID SELECT NLS_CHARSET_ID('UTF8') csid FROM DUAL;

2) ORA-31011: XML parsing failed. 2) ORA-31011: XML 解析失败。 ... LPX-00216: invalid character 31 (0x1F) It's means that oracle is not able to parse xml generated by clobfromblob. ... LPX-00216: invalid character 31 (0x1F) 这意味着 oracle 无法解析由 clobfromblob 生成的 xml。 invalid character 31 (0x1F) 0x1f is asci hex code for US (Unit Separator). invalid character 31 (0x1F) 0x1f 是美国的 asci 十六进制代码(单位分隔符)。 reason of this exception can be wrong encoding during conversion from blob to clob or invalid xml in blob data.此异常的原因可能是从 blob 转换为 clob 期间的错误编码或 blob 数据中的无效 xml。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM