以下正则表达式分隔逗号分隔的纯值
(SELECT regexp_substr(:pCsv,'[^,]+', 1, level)
FROM DUAL
CONNECT BY regexp_substr(:pCsv, '[^,]+', 1, level) IS NOT NULL);
例子:
300100033146068, 300100033146071 , 300100033146079
返回
300100033146068
300100033146071
300100033146079
如果我们将正则表达式与 SQL IN 运算符一起使用,则效果很好
select *
from mytable
where t.mycolumn IN (SELECT regexp_substr(:pCsv,'[^,]+', 1, level)
FROM DUAL
CONNECT BY regexp_substr(:pCsv, '[^,]+', 1, level) IS NOT NULL);
但如果逗号分隔值是单引号字符串文字,则此查询不起作用
'one' , ' two' , 'three'