oracle clob 分割,Oracle clob字符串分割函数

标签:

/******************************************************

ORACLE clob字符串分割函数

首先创建以下type

create or replace type type_str is table of varchar2(1000);

*******************************************************/

FUNCTION FUNC_SPLIT_CLOB(P_STR IN CLOB, P_DELIMITER IN VARCHAR2 DEFAULT ','/*, LEN IN OUT NUMBER*/) RETURN TYPE_STR

AS

RS TYPE_STR := TYPE_STR();

L_STR CLOB := P_STR;

L_DELIMITER CLOB:= TO_CLOB(P_DELIMITER);

L_LEN NUMBER := 0;

N NUMBER;

V_STR VARCHAR2(32767);

LEN NUMBER;

BEGIN

L_LEN := LENGTH(P_DELIMITER);

DBMS_LOB.APPEND(DEST_LOB => L_STR,SRC_LOB =>L_DELIMITER);

LOOP

N := DBMS_LOB.INSTR(LOB_LOC => L_STR,PATTERN => L_DELIMITER);

V_STR:= TRIM(DBMS_LOB.SUBSTR(LOB_LOC => L_STR,AMOUNT => N-1,

你可能感兴趣的:(oracle,clob,分割)