oracle怎么判断包含,Oracle判断一个字符串是否包含另一个字符串

  • Post author:
  • Post category:其他


create or replace function tagSplit(v_a varchar2, v_b varchar2)

return number as

counta number;

countb number;

countc number;

Begin

counta := 0;

countb := 0;

countc := 0;

select count(1)

into counta

from (SELECT REGEXP_SUBSTR(v_a, ‘[^,]+’, 1, rownum) deptida

FROM DUAL

CONNECT BY ROWNUM <=

LENGTH(v_a) – LENGTH(REPLACE(v_a, ‘,’, ”)) + 1) aa,

(SELECT REGEXP_SUBSTR(v_b, ‘[^,]+’, 1, rownum) deptidb

FROM DUAL

CONNECT BY ROWNUM <=

LENGTH(v_b) – LENGTH(REPLACE(v_b, ‘,’, ”)) + 1) bb

where aa.deptida = bb.deptidb;

select count(1)

into countb

from (SELECT REGEXP_SUBSTR(v_b, ‘[^,]+’, 1, rownum) deptidb

FROM DUAL

CONNECT BY ROWNUM <=

LENGTH(v_b) – LENGTH(REPLACE(v_b, ‘,’, ”)) + 1) bb;

if counta = countb then

countc := 1;

return countc;

end if;

return countc;

end tagSplit;