且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 oracle 中的函数拆分为具有自动序列的逗号分隔值

更新时间:2023-11-20 19:27:52

以下是创建此类表的方法:

Here is how you could create such a table:

 SELECT LEVEL AS id, REGEXP_SUBSTR('A,B,C,D', '[^,]+', 1, LEVEL) AS data
   FROM dual
CONNECT BY REGEXP_SUBSTR('A,B,C,D', '[^,]+', 1, LEVEL) IS NOT NULL;

稍加调整(即,将 [^,] 中的 , 替换为一个变量),您就可以编写这样一个函数来返回一个表.

With a little bit of tweaking (i.e., replacing the , in [^,] with a variable) you could write such a function to return a table.