Oracle中一个自定义的拆分字符串的函数 各种不懂求详细讲解
FUNCTIONF_SPLIT(I_STRINVARCHAR2,I_DELIMITERINVARCHAR2)RETURNT_STR_SPILTISjINT:=0;iINT...
FUNCTION F_SPLIT (I_STR IN VARCHAR2, I_DELIMITER IN VARCHAR2)
RETURN T_STR_SPILT
IS
j INT := 0;
i INT := 1;
len INT := 0;
len1 INT := 0;
str VARCHAR2 (4000);
str_split T_STR_SPILT := T_STR_SPILT ();//1
BEGIN
len := LENGTH (I_STR);
len1 := LENGTH (I_DELIMITER);
WHILE j < len LOOP
j := INSTR (I_STR, I_DELIMITER, i);
IF j = 0 THEN
j := len;
str := SUBSTR (I_STR, i);
str_split.EXTEND;
str_split (str_split.COUNT) := str;//2
IF i >= len THEN
EXIT;
END IF;
ELSE
str := SUBSTR (I_STR, i, j - i);
i := j + len1;
str_split.EXTEND;
str_split (str_split.COUNT) := str;
END IF;
END LOOP;
RETURN str_split;
END F_SPLIT;
主要解释一下//1 和//2 的语句,希望回答的人能耐心讲解,小弟不胜感激~ 展开
RETURN T_STR_SPILT
IS
j INT := 0;
i INT := 1;
len INT := 0;
len1 INT := 0;
str VARCHAR2 (4000);
str_split T_STR_SPILT := T_STR_SPILT ();//1
BEGIN
len := LENGTH (I_STR);
len1 := LENGTH (I_DELIMITER);
WHILE j < len LOOP
j := INSTR (I_STR, I_DELIMITER, i);
IF j = 0 THEN
j := len;
str := SUBSTR (I_STR, i);
str_split.EXTEND;
str_split (str_split.COUNT) := str;//2
IF i >= len THEN
EXIT;
END IF;
ELSE
str := SUBSTR (I_STR, i, j - i);
i := j + len1;
str_split.EXTEND;
str_split (str_split.COUNT) := str;
END IF;
END LOOP;
RETURN str_split;
END F_SPLIT;
主要解释一下//1 和//2 的语句,希望回答的人能耐心讲解,小弟不胜感激~ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询