如果在复杂查询中使用 REGEXP_LIKE 需要很长时间才能执行,您能否为此提供替代解决方案。
从一个查询中获取值列表,并且应该仅将这些值用于另一个查询 where 子句
LV_TRANS_TYPES_IDS VARCHAR2(4000);
SELECT LISTAGG(TRANSACTION_TYPE_ID, '|') WITHIN GROUP(ORDER BY 1)
INTO LV_TRANS_TYPES_IDS
FROM MTL_TRANSACTION_TYPES
WHERE TRANSACTION_TYPE_NAME IN
(SELECT MEANING
FROM FND_LOOKUP_VALUES_VL
WHERE LOOKUP_TYPE = 'LOOKUPNAME');
-- 它将返回多个值,例如 2|38|45|60
LV_TRANS_TYPES_IDS := '^(' || LV_TRANS_TYPES_IDS || ')$';
-- 赋值 ^(2|38|45|60)$ 将此值传递给下面的查询
SELECT COUNT(*)
INTO LN
FROM MTL_TRANSACTION_TYPES
WHERE 1 = 1
AND REGEXP_LIKE(TRANSACTION_TYPE_ID, LV_TRANS_TYPES_IDS);
首先执行查询获取输出并将这些输出用于第二、第三个查询输入。like (select f1,f2 from table1 where REGEXP_LIKE(TRANSACTION_TYPE_ID, LV_TRANS_TYPES_IDS) union all union all select f1,f2 from table3 where REGEXP_LIKE(TRANSACTION_TYPE_ID, LV_TRANS_TYPES_IDS))