Create or Replace function f_split_condition (start_string VARCHAR2, V_flag VARCHAR2)
/**
* Replace the given START_STRINGN string with a comma-delimited string by V_flag
* For example: 12-34-56 replaced with ' 12 ', ' 34 ', ' 56 '
* Use loop Loop to implement
*/
RETURN VARCHAR2 is
L_string VARCHAR2 (100);--Output string
L_indx INTEGER; --Special characters
V_string VARCHAR2 (+): = start_string; --Original string
Begin
L_string: = "";--Initialize to a ' number
LOOP
L_indx: = INSTR (V_string,v_flag);--Find the location of special characters
IF l_indx > 0 Then
L_string: = L_string| | SUBSTR (v_string,1,l_indx-1);--cut out the first set of numbers, when the number is ' 12
V_string: = SUBSTR (V_string,l_indx + LENGTH (v_flag));--cut 12-off
L_string: = L_string| | ', ';--add ' after ' 12 ', at which time L_string is ' 12 '
ELSE
L_string: = L_string| | v_string;--the last one does not have to be cut, just add it to the last side.
EXIT;
END IF;
END LOOP;
L_string: = L_string| | "; --plus the last '
return (l_string);--Returns the last concatenation of the successful characters
End F_split_condition;
Oracle Custom Function: Converts special characters in a string to commas