oracle 字符串分隔去重函数

create or replace
FUNCTION "SF_SPLIT_ACCOUNT_ID_LIST" (
account_id_list IN VARCHAR2
)RETURN VARCHAR2 AS
v_account_id_list VARCHAR2(5000);

BEGIN

WITH ACCTS AS (
SELECT DISTINCT str from (
SELECT REGEXP_SUBSTR(replace(account_id_list,', ',','), '[^,]+', 1, LEVEL, 'i') AS STR
FROM DUAL
CONNECT BY LEVEL <=
LENGTH(replace(account_id_list,', ',','))
- LENGTH(REGEXP_REPLACE(replace(account_id_list,', ',','), ',', ''))+1))
SELECT wm_concat(STR) INTO v_account_id_list FROM ACCTS;

RETURN v_account_id_list;

END SF_SPLIT_ACCOUNT_ID_LIST;

posted @ 2019-05-20 14:07  冬天不眠  阅读(1491)  评论(0编辑  收藏  举报