Oracle处理指定分隔符中的字符串

DECLARE
  V_LENGTH NUMBER;
  V_TMP    VARCHAR2(10);
  V_STR    VARCHAR2(20) := '12;6;2;5;3';
BEGIN
  V_LENGTH := LENGTH(V_STR) - LENGTH(REPLACE(V_STR, ';', '')) + 1;
  FOR i IN 1..V_LENGTH LOOP
      SELECT REGEXP_SUBSTR(V_STR, '[^;]+', 1, i) INTO V_TMP FROM DUAL;
      DBMS_OUTPUT.put_line(V_TMP);
  END LOOP;
END;
/

你可能感兴趣的:(Oracle)