Oracle Custom Function: Converts special characters in a string to commas

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.