Oracle two comma-separated strings how to determine if they have the same value

Source: Internet
Author: User

Like what
Field A: ' Ab,cd,ef,gh '
Field B: ' Aa,bb,cc,dd ' does not have the same value

Field A: ' Ab,cd,ef,gh '
Field B: ' Aa,bb,cd,dd ' has the same value CD

1.CREATE OR REPLACE TYPE ty_str_split is TABLE of VARCHAR2 (4000);
2.CREATE OR REPLACE FUNCTION cux_pub_str_split (p_str in VARCHAR2, P_delimiter in VARCHAR2)
RETURN Ty_str_split pipelined
Is
J INT: = 0;
I INT: = 1;
Len INT: = 0;
Len1 INT: = 0;
STR VARCHAR2 (4000);
BEGIN
Len: = LENGTH (P_STR);
Len1: = LENGTH (P_delimiter);
While J < Len
LOOP
J: = INSTR (P_str, P_delimiter, i);
IF j = 0
Then
J: = Len;
str: = SUBSTR (P_str, i);
PIPE ROW (str);
IF I >= len
Then
EXIT;
END IF;
ELSE
str: = SUBSTR (P_str, I, j-i);
I: = j + len1;
PIPE ROW (str);
END IF;
END LOOP;
RETURN;
END Cux_pub_str_split;

3. test data can be converted into a table and then judged in the form of a table

or use Oracle to take the intersection function intersect

Select Regexp_substr (NME, ' [^,]+ ', 1, rownum) NME
From (SELECT ' Beijing, Hangzhou, Shanghai ' NME from dual)
Connect by rownum <= Length (Regexp_replace (NME, ' [^,]+ ')) +1
Intersect
Select Regexp_substr (NME, ' [^,]+ ', 1, rownum) NME
From (SELECT ' Beijing, Shanghai, Sichuan, Zhengzhou ' NME from dual)
Connect by rownum <= Length (Regexp_replace (NME, ' [^,]+ ')) +1;

Oracle two comma-separated strings how to determine if they have the same value

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.