oracle分割字符并判断是否在此字符中

oracle分割字符并判断是否在此字符中

CREATE OR REPLACE FUNCTION splitandcheck (

    p_str IN VARCHAR2,

    p_delimiter IN VARCHAR2 default(','), --分隔符,默认逗号

    p_substring in varchar2

)

RETURN number

IS

j INT := 0;

i INT := 1;

len INT := 0;

len1 INT := 0;

str VARCHAR2 (4000);

BEGIN

len := LENGTH (p_str);

len1 := LENGTH (p_delimiter);

WHILE j < len

LOOP

j := INSTR (p_str, p_delimiter, i);

IF j = 0

THEN

j := len;

str := SUBSTR (p_str, i);

IF str = p_substring

THEN

return 1;

END IF;

ELSE

str := SUBSTR (p_str, i, j - i);

i := j + len1;

IF str = p_substring

THEN

return 1;

END IF;

END IF;

END LOOP;

return 0;

END splitandcheck;

你可能感兴趣的:(oracle,数据库)