求一段用ql/sql编程判断一个字符串中的每个字符是否在另一个字符串中存在的代码

解决方案 »

  1.   

    对其中一个遍历就好了
    create or replace procedure proc(str1 in varchar2,str2 in varchar2)
    as
    begin
      if str1 is null or str2 is null then
        dbms_output.put_line('Error,A string is null!');
        return;
      end if;
      for i in 1..length(str1) loop
        if instr(str2,substr(STR1,i,1))>0 then
          dbms_output.put_line('Find!');
          return;
        end if;
      end loop;
      dbms_output.put_line('Not Found!');
    end proc;
    调用
    begin
      proc('ee','cba');
    end;
      

  2.   

    结果在output窗口里
    如果在command窗口中,set serviceoutput on
    如果想要作为返回值在查询窗口中显示,改成函数就好了
      

  3.   

    create or replace procedure proc(str1 in varchar2,str2 in varchar2)
    as
    begin
      if str1 is null or str2 is null then
        dbms_output.put_line('Error,A string is null!');
        return;
      end if;
      for i in 1..length(str1) loop
        if REGEXP_LIKE(czPOIName,' ||'''.*''' || '||substr(,' || i || ',1)||' || '''.*''' ||'||d.onechar||' || '''.*''' || ') then
          dbms_output.put_line('Find!');
          return;
        end if;
      end loop;
      dbms_output.put_line('Not Found!');
    end proc;
    LS是对的