Oracle反向字符截取逗號分隔字符串
时间:2021-07-01 10:21:17
帮助过:2人阅读
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()函數反轉子串。
Oracle反向字符截取逗號分隔字符串
标签: