Orale查询返回相似度基数个数

create or replace function FUN_GET_CUSTOMER_NAME_PERCENT(customerName varchar2,key varchar2)
  return NUMBER
IS
percent number;--返回百分数
like_num number;--相似度基数个数
str varchar2(500);
len number;
begin
len:=LENGTH(key);
like_num:=0;
For i in 1..len LOOP
str:=substr(key,i,1);
if instr(customerName,str,1,1)>0 then
like_num:=like_num+1;
end if;
end LOOP;
percent:=like_num/len;
dbms_output.put_line(like_num);
return(percent);
end;

posted @ 2013-02-22 14:11  天纯蓝  阅读(189)  评论(0编辑  收藏  举报