BLOB 到 XMLType XML 在 Oracle 中解析失败

BLOB to XMLType XML parsing failed in oracle

我无法在 Oracle 数据库中将 BLOB 转换为 XMLType。 我试过这个:

select
XMLType( BLOB_COLUMN,
         1 /* this is character set ID. 1 == USASCII | ISO-8859-2 char ID?*/
       ) as XML
from my_table;

我收到此错误消息:

ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00200: could not convert from encoding US-ASCII to ISO-8859-2
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 265
ORA-06512: at line 1
31011. 00000 -  "XML parsing failed"
*Cause:    XML parser returned an error while trying to parse the document.
*Action:   Check if the document to be parsed is valid.

我的问题是,如何将此 BLOB (ISO-8859-2) 转换为 XMLType? ISO-8859-2 的字符 ID 是什么?

谢谢。

使用nls_charset_id获取ID:

select
XMLType( BLOB_COLUMN,
         nls_charset_id('ISO-8859-2')
       ) as XML
from my_table;

NLS_CHARSET_ID returns the character set ID number corresponding to character set name string.

您可以通过nls_charset_id函数获取字符集ID。

试试这个:

select
XMLType( BLOB_COLUMN,
         nls_charset_id('EE8ISO8859P2')
   ) as XML
from my_table;