我有一张桌子员工:
CREATE TABLE EMP
(ID NUMBER,
DES CLOB);
表中实际数据:
id desc
1 I have pen in India
2 My name is pravin
当数据长度大小超过6时使用循环创建函数,然后其他数据是oracle中的下一行。
输出
id desc
1 I have
1 pen i
1 n India
2 My nam
2 e is p
2 ravin
将 clob 转换为 varchar
激发查询将代码包装在您需要的函数中:
with data(id, txt) as (
select 1, empty_clob() || 'I have pen in India' union all
select 2, empty_clob() || 'My name is pravin'
)
select id, dbms_lob.substr(txt, 6, 6*(level - 1)+1) as descr
from data
connect by prior id = id and dbms_lob.substr(txt, 6, 6*(level - 1)+1) is not null and prior sys_guid() is not null
;