比对两个传入的字符串是否含有相同的字符串,并返回相同的数量
create or replace function checkContainStr
/******************************
description:比对两个传入的字符串是否含有相同的字符串,并返回相同的数量
author:lwh date:2011-12-18 ver:1.0
********************************/
(strSource in varchar2,strTarget
in varchar2,splitMark
in varchar2)
return pls_integer
as
j INT :
= 0;
i INT :
= 1;
len INT :
= 0;
len1 INT :
= 0;
str VARCHAR2 (
4000);
counts pls_integer:=0;
begin
len :
= LENGTH (strSource);
len1 := LENGTH (splitMark);
WHILE j
< len
LOOP
j := INSTR (strSource, splitMark, i);
IF j
= 0
THEN
j := len;
str :
= SUBSTR (strSource, i);
if instr(strTarget,
str)
>0 then
counts:=counts
+1;
end if;
IF i
>= len
THEN
EXIT;
END IF;
ELSE
str :
= SUBSTR (strSource, i, j
- i);
i := j
+ len1;
if instr(strTarget,
str)
>0 then
counts:=counts
+1;
end if;
END IF;
END LOOP;
RETURN counts;
end;
posted on
2012-05-09 14:52
蓝红石 阅读(
...) 评论(
)
编辑
收藏
转载于:https://www.cnblogs.com/liuweihua/archive/2012/05/09/2491770.html