There are two ways of accommodating Dynamic IN lists:
- Convert the comma separated list into a derived table (AKA inline view)
- Use dynamic SQL
Non-Dynamic
Most prefer the non-dynamic SQL approach - this link provides various ways to do it. The biggest reason to use this over:
WHERE :list LIKE '%,' || t.column || ',%'
...is that the above:
- Will never be able to use an index
- Won't be able to match the first or last parameter in the list, because commas are required on either end to match
The simple fact is, it won't work as intended. A regex, supported on Oracle 10g+, would allow for conditional checking on the column but still faces the problem of rendering an index as moot
Dynamic SQL
Mention "dynamic SQL", and you likely will be hounded about SQL injection attacks. Using a bind variable alleviates the concern.
That said, dynamic SQL requires the least change to the query.