Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Transform text for IN clause?

Re: Transform text for IN clause?

From: Urs Metzger <urs_at_vornamenachname.de>
Date: Thu, 10 Mar 2005 00:38:43 +0100
Message-ID: <d0o18i$n7e$1@online.de>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US