Boern
Boern

Reputation: 7752

Oracle SQL: Use IN operator with inline array

Is it possible to define an inline array to use with the IN operator in Oracle SQL 12c? Pseudo code:

SELECT *
FROM T_AUDIO_PLAYERS
WHERE NAME IN {'foo', 'bar'};

Background: I have a Java tool, that's reading in valid .SQL files and replaces SQL-Variables like :NAME before execution.

Upvotes: 0

Views: 497

Answers (2)

Muhammad Muazzam
Muhammad Muazzam

Reputation: 2800

You can use LISTAGG function like

SELECT *
FROM T_AUDIO_PLAYERS
WHERE NAME IN (select LISTAGG() ...);

More detail here

Upvotes: 0

swebbo
swebbo

Reputation: 308

I am not sure if I understand your question correctly. However, if you change your {-brackets to (-brackets, this should already work:

SELECT *
FROM T_AUDIO_PLAYERS
WHERE NAME IN ('foo', 'bar');

Upvotes: 2

Related Questions