--DBMS_LOB.substr不加参数表示全部截取,负向截取待定
CREATE OR REPLACE FUNCTION CLOB_SUBSTR(
V_CLOB CLOB,
N_OFFSET NUMBER)
RETURN CLOB
AS
N_BATCH NUMBER;
O_CLOB CLOB;
BEGIN
N_BATCH:=CEIL(DBMS_LOB.GETLENGTH(V_CLOB)/4000);
FOR I IN 1..N_BATCH LOOP
O_CLOB:=O_CLOB||DBMS_LOB.substr(V_CLOB,4000,N_OFFSET+(I-1)*4000);
END LOOP;
RETURN O_CLOB;
END;
/