oracle blob转成字符串
2019-07-05 本文已影响13人
默直
oracle blob转字符串
blob长度有三种:小于2000、大于2000,小于4000、blob长度大于4000,不同的长度,对应不同的编写方式,以下就对其进行简单讲解:
首先,blob长度小于2000:
blob长度小于2000SELECT
ID,
utl_raw.cast_to_varchar2 (dbms_lob.substr (clume_name))
FROM
A
其次,blob长度大于2000,小于4000:
blob长度大于2000,小于4000SELECT
ID,
utl_raw.cast_to_varchar2 (DBMS_LOB.SUBSTR (colume_name, 2000, 1))
||
utl_raw.cast_to_varchar2 (DBMS_LOB.SUBSTR (colume_name, 2000, 2001))
FROM
A
在次,blob长度大于4000:
blob长度大于4000SELECT
ID
,utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(colume_name,2000,1)) colume_name1
,utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(colume_name,2000,2001)) colume_name2
,utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(colume_name,2000,4001)) colume_name3
FROM A
当blob长度大于4000,请不要使用拼接字段的方式,这样会出现错误。
错误拼接(完)