日期:2014-05-16 浏览次数:20573 次
FUNCTION strContain(str1 IN VARCHAR2, str2 IN VARCHAR2)
RETURN NUMBER IS
Result NUMBER;
var_str1Index number;
var_str2Index number;
var_str1 type_split;
var_str2 type_split;
var_str1Split varchar2(100);
var_str2Split varchar2(100);
BEGIN
Result := 0;
--先拆分字符串
var_str1 := split_str(str1,',');
var_str2 := split_str(str2,',');
var_str1Index :=var_str1.first;
var_str2Index :=var_str2.first;
--在循环的逐个比较
while (var_str1Index is not null) loop
var_str1Split := var_str1(var_str1Index);
dbms_output.put_line(var_str1Index||'-->'||var_str1Split);
while (var_str2Index is not null ) loop
var_str2Split := var_str2(var_str2Index);
dbms_output.put_line(var_str2Index ||'==>'||var_str2Split);
if(var_str1Split = var_str2Split) then
return 1;
end if;
var_str2Index :=var_str2.next(var_str2Index);
end loop;
var_str2Index :=var_str2.first;
var_str1Index := var_str1.next(var_str1Index);
end loop;
RETURN Result;
END strContain;
?--查看2个字符串是否匹配 包含:1 不包含:0(str1:aa,bb,cc str2: aa,bb)