为什么你将数字列表存储为字符串?
无论如何,一种可能的解决方案是这个。像这样创建 TYPE 和 FUNCTION:
CREATE OR REPLACE TYPE NUMBER_TABLE_TYPE AS TABLE OF NUMBER;
CREATE OR REPLACE FUNCTION SplitArray(LIST IN VARCHAR2, Separator IN VARCHAR2) RETURN NUMBER_TABLE_TYPE IS
OutTable NUMBER_TABLE_TYPE;
BEGIN
IF LIST IS NULL THEN
RETURN NULL;
ELSE
SELECT REGEXP_SUBSTR(LIST, '[^'||Separator||']+', 1, LEVEL)
BULK COLLECT INTO OutTable
FROM dual
CONNECT BY REGEXP_SUBSTR(LIST, '[^'||Separator||']+', 1, LEVEL) IS NOT NULL;
END IF;
IF OutTable.COUNT > 0 THEN
RETURN OutTable;
ELSE
RETURN NULL;
END IF;
END SplitArray;
然后您查询一个数字,如下所示:
WHERE 16071 MEMBER OF SplitArray(a.IDs, ',')
或几个这样的数字:
WHERE SplitArray(b.IDs, ',') SUBMULTISET OF SplitArray(a.IDs, ',')
查看多组条件