I am try to use the Mule Database Connector, Select Operation to run a query with multiple WHERE * OR *
clauses which are created dynamically from an array. What is the best way to do this?
Something like:
SQL Query Text:
SELECT
C1,
C2
FROM T
WHERE C1 = 'A'
OR C1 = 'B'
OR C1 = 'C'
Which is created from:
payload = ['A', 'B', 'C']
Where payload is of variable length.
I know I can use a Query single operation in a For Each loop, but I would like to use a bulk query for efficiency if possible.
You can use IN clause and joinBy operator for the array elements like
#["SELECT
C1,
C2
FROM T
WHERE C1 IN (" ++ payload joinBy "," ++ ")"]
HTH