Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Transform text for IN clause?
Angrydot schrieb:
> Greetings,
>
> I have a text variable A = 't1:t2:t3' that I would like to use in the
> SQL IN clause (i.e. SELECT * FROM X WHERE c IN (A);).
>
> I tried REPLACE and TRANSFORM with no success. For example IN
> (REPLACE(a,':',''',''')).
>
> Is there a way to do this directly in the SQL statement and not using
> PL/SQL or VB?
Here we go (Oracle 10g):
SQL> create table t(x varchar2(1));
Tabelle wurde angelegt.
SQL> insert into t values('A');
1 Zeile wurde erstellt.
SQL> insert into t values('C');
1 Zeile wurde erstellt.
SQL> insert into t values('E');
1 Zeile wurde erstellt.
SQL> variable inlist varchar2(100);
SQL> exec :inlist := 'A:B:C';
PL/SQL-Prozedur wurde erfolgreich abgeschlossen.
SQL> select * from t where ':' || :inlist || ':' LIKE '%:' || x || ':%';
X
-
A
C
hth, Urs Received on Wed Mar 09 2005 - 17:38:43 CST
![]() |
![]() |