CREATE OR REPLACE FUNCTION splitArrayLength ( v_source IN VARCHAR2, v_delimiter IN VARCHAR2 ) RETURN INT IS j INT := 0; i INT := 1; len INT := 0; delim_len INT := 0; cnt INT := 0; BEGIN len := length( v_source ); delim_len := length( v_delimiter ); WHILE j < len LOOP j := instr( v_source, v_delimiter, i ); IF j = 0 THEN j := len; cnt := cnt + 1; IF i >= len THEN EXIT; END IF; ELSE i := j + delim_len; cnt := cnt + 1; END IF; END LOOP; RETURN cnt; END splitArrayLength;
select splitArrayLength(tdyh, ',') num from TD_ANALYSE_TDJL_GX