Oracle SQL writes a method to determine whether a string is a function in the target string based on requirements. Used to identify the following situations: Determine whether string A exists in string B separated by commas (,), for example: www.2cto.com v_str_a = aa; v_str_ B = aa, bb, dd, cc; as shown above, returns Y; otherwise, returns N. Some verifications are added. You can extract strings Based on the specified delimiter as needed. After all, Oracle's String Parsing is troublesome and can be encapsulated. SQL code uses create or replace function compute (p_target varchar2, p_str_array varchar2) return varchar2 is v_flag varchar2 (1); v_comma_loc int; v_cut_string varchar2 (300); v_rest_string varchar2 (2000 ); begin ------------------------ -- p_target cannot contain ","!!! Note !! -- Info: This function is used to identify the target string. whether to use "," to separate the strings ---------------------- v_flag: = 'n'; v_comma_loc: = instr (p_str_array ,', '); -- if the comparison string is null, false is returned if nvl (p_str_array, '') = ''then return 'n'; end if; -- if there is no comma, directly compare if length (p_str_array)> 0 and v_comma_loc = 0 then if p_target = p_str_array then return 'y'; else return 'n'; end if; v_rest_string: = p_str_array; while v_comma_loc> 0 loop v_cut_string: = substr (v_rest_string, 0, v_comma_loc-1); v_rest_string: = substr (v_rest_string, v_comma_loc + 1, length (v_rest_string) -1); if p_target = v_cut_string then v_flag: = 'y'; end if; v_comma_loc: = instr (v_rest_string ,','); if v_comma_loc = 0 and length (v_rest_string)> 0 then if p_target = v_rest_string then v_flag: = 'y'; end if; end loop; return v_flag; end;