The IN operator in SQL requires that the list you match against be contained in parentheses, like so:
SELECT *
FROM my_table
WHERE column_name IN ('value1', 'value2')
I'd like to provide the comma separated list of values using a variable. But, if I include the parentheses in the variable, and try to evaluate the variable directly after IN, I get an error.
my_string_with_parens_in_it = "('value1', 'value2')"
WHERE column_name IN @{my_string_with_parens_in_it}
If we move the parentheses out of the variable, and they are instead part of the query (as seems right to me), the variable is not evaluated properly, and no records are found.
my_string_without_parens = "'value1', 'value2'"
WHERE column_name IN (@{my_string_without_parens})
Storing the value of the variable in an ADOR (and then generating a proof set) shows that it is being set correctly. Copy/pasting that value directly into the query makes it work, so this seems like an XMPie issue. Has anyone used a variable in this way?
Thanks very much for your time!
Jon Strand