zoukankan      html  css  js  c++  java
  • oracle | 判断str1是否包含str2

    /**
     * 判断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;
    

      

  • 相关阅读:
    nyoj 16 矩形嵌套
    nyoj 44 子串和
    nyoj 448 寻找最大数
    nyoj 14 会场安排问题
    hdoj 1008 Elevator
    bzoj1588
    bzoj3224
    bzoj1503
    bzoj1834
    bzoj1066
  • 原文地址:https://www.cnblogs.com/xder/p/5152370.html
Copyright © 2011-2022 走看看