select '18776' as instanceid from dual union all
select '18775' as instanceid from dual
或者
select column_value from table(sys.odcivarchar2list('18776', '18775'))
或某种分层查询,可以将您的逗号分隔字符串拆分为一组 varchar。
将这些与您的初始查询联合起来。
更新:“我不只处理 2 个静态值,它是一个任意列表。”
仍然可以作为集合传递给查询(以下只是许多可能的方法之一)
23:15:36 LKU@sandbox> ed
Wrote file S:\spool\sandbox\BUFFER_LKU_39.sql
1 declare
2 cnt int := 10;
3 coll sys.odcivarchar2list := sys.odcivarchar2list();
4 begin
5 coll.extend(cnt);
6 for i in 1 .. cnt loop
7 coll(i) := dbms_random.string('l', i);
8 end loop;
9 open :result for 'select * from table(:c)' using coll;
10* end;
23:37:03 11 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.50
23:37:04 LKU@sandbox> print result
COLUMN_VALUE
-------------------------------------------------------------
g
kd
qdv
soth
rvwnq
uyfhbq
xxvxvtw
eprralmd
edbcajvfq
ewveyljsjn
10 rows selected.
Elapsed: 00:00:00.01