首页 > 数据库技术 > 详细

oracle | 判断str1是否包含str2

时间:2016-01-23 00:55:06      阅读:197      评论:0      收藏:0      [点我收藏+]
/**
 * 判断str1是否包含str2.
 * @param str1 数组型字符串,以逗号分割
 * @param str2
 * @return 如果str1包含str2,则返回1,否则返回-1
 * @Author: xDer
 */
create or replace function exinstr(str1 in varchar2, str2 in varchar2)
return integer as
  Result integer;
  v_column_value varchar2(4000);
  cursor cur is
  select column_value from table(fn_split(str1,‘,‘));
  c_row cur%rowtype;

begin
  open cur;
  loop
    fetch cur into c_row;
    exit when cur%notfound;
    v_column_value := c_row.column_value;
    if v_column_value = str2 then
     Result := 1;
     return(Result);
     exit;
    else
     continue;
    end if;
  end loop;
  close cur;
  
  Result :=-1;
  
  return(Result);
  
   exception when others then 
    begin
        Result := -1;
        return(Result);
    end;
  
end exinstr;

  

oracle | 判断str1是否包含str2

原文:http://www.cnblogs.com/xder/p/5152370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!