DECLARE M VARCHAR(10); BEGIN FOR I IN ( WITH T AS (SELECT REVERSE('i,am,a,test,hahahhah') AS STR FROM DUAL) SELECT LEVEL, REGEXP_SUBSTR(T.STR, '[^,]+', 1, LEVEL) STR_SINGLE FROM T CONNECT BY LEVEL <= LENGTH(T.STR) - LENGTH(REPLACE(T.STR, ',', '')) + 1) LOOP SELECT REVERSE(I.STR_SINGLE) INTO M FROM DUAL; DBMS_OUTPUT.PUT_LINE(M); END LOOP; END;
使用 REVERSE()函數反轉子串。