简体   繁体   English

转换功能不适用于CLOB数据类型

[英]Convert function not working with CLOB datatype

We have some data of type lob and varchar2 which is wrongly encoded to AL32UTF8and we need to convert its encoding to we8mswin1252 character set. 我们有一些lob和varchar2类型的数据,它们被错误地编码为AL32UTF8,我们需要将其编码转换为we8mswin1252字符集。 I got convert function which is used for character set conversion and this function is working fine with varchar2 datatype but its giving some fuzzy characters when used with CLOB. 我有用于字符集转换的转换函数,该函数在varchar2数据类型上正常工作,但与CLOB一起使用时会产生一些模糊字符。 My current encoding is AL32UTF8. 我当前的编码是AL32UTF8。

 select value,CONVERT(value,'we8mswin1252','AL32UTF8'),CONVERT(to_clob(value),'we8mswin1252','AL32UTF8') from temp;

在此处输入图片说明

Database: Oracle 12c 数据库:Oracle 12c

select * from nls_database_parameters where parameter like  '%CHARACTERSET%';

在此处输入图片说明

Answer I got from Oracle: "The CONVERT function is a legacy function that should not be used for any application-related character set conversion. CLOB is especially tricky as it uses a special storage encoding in multibyte databases, such as AL32UTF8. CONVERT is useful for some repair tasks only. The supported way of processing data in character sets other than the database character set is to use the RAW data type and the conversion procedures from the package UTL_I18N. However, UTL_I18N does not support CLOBs. Therefore, you do have to read CLOBs in 32K chunks, convert them to WE8MSWIN1252 with UTL_I18N.STRING_TO_RAW, do your post-processing and write the file with UTL_FILE.PUT_RAW." 我从Oracle那里得到的答案:“ CONVERT函数是一个遗留函数,不应用于任何与应用程序相关的字符集转换。CLOB尤其棘手,因为它在多字节数据库(例如AL32UTF8)中使用了特殊的存储编码。CONVERT非常有用仅用于某些修复任务。在数据库数据库字符集以外的字符集中处理数据的支持方式是使用RAW数据类型和程序包UTL_I18N中的转换过程。但是,UTL_I18N不支持CLOB。要读取32K块的CLOB,请使用UTL_I18N.STRING_TO_RAW将其转换为WE8MSWIN1252,进行后期处理并使用UTL_FILE.PUT_RAW写入文件。

Also I got another unix command iconv which converts file encoding so basically I was writing db output to file so converted its encoding and transfered the data. 我还得到了另一个unix命令iconv来转换文件编码,所以基本上我是将db输出写入文件,因此转换了它的编码并传输了数据。

Thanks 谢谢

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

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