分类文章

热门文章

oracle 比较字符串包含关系

该方法用来比较一个字符串是否包含另一个字符串

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CREATE OR REPLACE FUNCTION strContent(str1 IN VARCHAR2, str2 IN VARCHAR2)
  RETURN NUMBER IS
  Result     NUMBER;
  sStr       VARCHAR2(255);
  scharacter VARCHAR2(255);
  iIndex     NUMBER;
  sTemp      VARCHAR2(255);
BEGIN
  Result     := 0;
  scharacter := str1;
  sStr       := str2;
  iIndex     := INSTR(sStr, ',', 1);
  WHILE (iIndex > 0) LOOP
    iIndex := INSTR(sStr, ',', 1);
    IF (iIndex > 0) THEN
      sTemp := SUBSTR(sStr, 0, iIndex - 1);
    ELSE
      sTemp := sStr;//sTemp是str2拆分后的某一个字符串
    END IF;
    Result := INSTR(scharacter, sTemp, 1);//检查str1中出现sTemp的位置
    IF Result > 0 THEN
      RETURN Result;
    END IF;
        sStr := SUBSTR(sStr, iIndex + 1, LENGTH(sStr));
  END LOOP;
  RETURN Result;
END strContent;

随机文章



分享生活也赚钱,赶快加入吧

Loading…

相关文章:

  1. oracle 实现字符串split
  2. oracle 合并列数据
  3. Oracle10g的SQL正则表达式

请给本文打分   
1 Star2 Stars3 Stars4 Stars5 Stars (20 votes, average: 3.60 out of 5)
Loading ... Loading ...

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word