问题
Oracle中将 clob
类型通过 to_char
转换为字符串类型时,如果clob内容过长,会转换失败,报ORA-64203的错误
解决方法
使用 DBMS_LOB.SUBSTR
代替 to_char
将 clob
转成 varchar2
, 第一个参数是字段名,第二个参数是截取多长,第三个参数是从什么位置开始截
注意:varchar2
是有长度限制的,最大值4000
DBMS_LOB.SUBSTR(lONG_CONTENT, 2000, 1)
官方说明
Database: 11g Release 2
Error code: ORA-64203
Description: Destination buffer too small to hold CLOB data after character set conversion.
Cause: An attempt was made to convert CLOB to CHAR, where the LOB size was bigger than the buffer limit for CHAR types or the CHAR buffer was not big enough to hold all data after character set conversion.
Action: Do one of the following: * Make the LOB smaller before performing the conversion. for example, by using SUBSTR on CLOB * Use DBMS_LOB.SUBSTR to convert CLOB to CHAR.