可能重复:
是否有在 plsql 中拆分字符串的函数?
我有以下 oracle 功能
create or replace
function FUN_CUSTID(t in varchar2)
RETURN VARCHAR2
IS
TYPE str_array2 IS TABLE OF VARCHAR2(100);
v_names str_array2;
v_condition varchar2(1000);
BEGIN
v_condition := '(';
select REGEXP_SUBSTR(t, '[^ ,]+', 1, rownum)
bulk collect into v_names
from DUAL
connect by level <= length (regexp_replace(t, '[^ ,]+')) + 1;
FOR indx in v_names.FIRST..v_names.LAST LOOP
if (indx = v_names.LAST) then
v_condition := v_condition || '''' || v_names(indx) ||'''';
else
v_condition := v_condition || '''' || v_names(indx) ||''',';
end if;
v_condition := v_condition || ')';
END LOOP;
return v_condition;
end FUN_CUSTID;
/
现在我想从 where 子句中调用这个函数
SELECT customer_id,
name_remark,
wbs_id,
service_circuit_id,
sum(actual_minutes) TOTAL_USAGE,
min(first_connection_time) DATE_FROM,
max(first_connection_time) DATE_TO,
sum(amount) AMOUNT
FROM temp
FROM customer_id IN (SELECT FUN_CUSTID('CUST00001,CUST00002') FROM DUAL)
GROUP BYcustomer_id, name_remark, wbs_id, service_circuit_id
ORDER BY customer_id;
当我直接运行此函数并替换值以代替上层查询中的函数调用时,它可以完美地处理某些记录,但上层查询无法正常工作。
如何在where子句中调用函数?