where column = any (string_to_array(replace(delimSources,' ',''),',')) -- replace(source,old, new) => removes whitespace -- string_to_array(source,separator) => puts the string separated by seperator in an array -- any => equivalent to IN, BUT in contrast to IN it can take an array, wheras IN takes a comma separated list -- https://stackoverflow.com/questions/34627026/in-vs-any-operator-in-postgresql
Normally you would write something like this : WHERE column IN (‘bingo’,’bongo’)
But passing comma separated variables into a function does not seem to allow the use of the variable directly in the IN condition. Instead we can convert that string to an array and then check the condition with any().
In MSSQL you seem to have the same problem, and there seem to be 2 kind of workarounds.
- Either create a dynamic query and execute that with exec()
- Create a tabe valued function