Oracle数据库按正则切割字符串

匿名 (未验证) 提交于 2019-12-03 00:03:02

1、方法一:

SELECT regexp_substr('161,83,66,81','[0-9]+',1,LEVEL) FROM dual CONNECT BY  level <= length('161,83,66,81') - length(regexp_replace('161,83,66,81',',','')) + 1;

另附流程备份如下(注意最后的分号在流程中是否需要):

SELECT ID ,DEPARTMENTID ,LASTNAME  FROM HRMRESOURCE WHERE LOGINID IS NOT NULL AND DEPARTMENTID IN (SELECT regexp_substr(t.deptid,'[0-9]+',1,LEVEL) FROM (SELECT (CASE to_char(DEPARTMENTID) WHEN to_char(161) THEN 161||','||81||','||66||','||83 ELSE to_char(DEPARTMENTID) END ) deptid FROM HRMRESOURCE WHERE DEPARTMENTID = 161) t CONNECT BY  level <= length(t.deptid) - length(regexp_replace(t.deptid,',','')) + 1) AND LASTNAME NOT LIKE '%离职%';

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!